borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (print TIF picture)Next Topic (I don't know any thing about printing!!How can i print a simple text??) New Topic New Poll Post Reply
AndreaVB Forum : Printing : printing picture (datareport)
Poster Message
doup
Level: Scholar

Registered: 16-06-2004
Posts: 32

icon printing picture (datareport)

hi, if you have been wondering how to print picture object in your datareport(picture stored in the database let say MS ACCESS) here is the simple approch. first your picture must be stored in binary format so you will have among other fields these 2 fields picture field (object-binary) and fileLeigth(long -data type).

in ur data report put image object in any section(section1)
declaration of few variable
      
Dim ByteData() As Byte
      Dim DestFileNum As Integer
      Dim DiskFile, pif As String
      Dim FileLength As Long
    
'open your database and connect to the table

If Rs!FileLength > 0 Then
                DiskFile = ""
                DiskFile = App.Path & "\picfile.bmp"

                If Len(Dir$(DiskFile)) > 0 Then
                    Kill DiskFile
                End If

                FileLength = Rs.Fields("fileLength").Value
                DestFileNum = FreeFile
                Open DiskFile For Binary As DestFileNum

                Numblocks = FileLength / BlockSize
                LeftOver = FileLength Mod BlockSize

                ByteData() = Rs("picture_field").GetChunk(LeftOver)
                Put DestFileNum, , ByteData() 'write data from a variable to disk file

                For i = 1 To Numblocks
                    ByteData() = Rs("picture_field").GetChunk(BlockSize)
                    Put DestFileNum, , ByteData()
                Next i

                Close DestFileNum
                picf = App.Path & "\picfile.bmp"

           End If
        Erase ByteData
        
        Set drMember.DataSource = Rs

'trick  we writepicture file  to HD then read it from there
Set Me.Sections("Section1").Controls.Item("Image2").Picture = LoadPicture(picf)
end if

hope it can helps  

[Edited by doup on 26-01-2005 at 02:02 PM GMT]

[Edited by doup on 09-02-2005 at 11:17 AM GMT]

____________________________
peter

26-01-2005 at 12:00 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Printing : printing picture (datareport)
Previous Topic (print TIF picture)Next Topic (I don't know any thing about printing!!How can i print a simple text??) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder