Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Display a blob image

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Data Objects Support
View previous topic :: View next topic  
Author Message
WaqasK



Joined: 21 Oct 2006
Posts: 32

PostPosted: Sun Dec 03, 2006 4:47 pm    Post subject: Display a blob image Reply with quote

Guys,

I'm having trouble displaying a blob image from a mySQL database in the Virtual Tree. I used the following code to display the image through a VDO recordset:

Code:
    Public Property Flag() As Image
        Get
            Dim photoField As ADODB.Field = Fields("Flag")
            Dim sPhoto As Image = Nothing
            If photoField.ActualSize > 0 Then
                Dim data As Byte() = CType(photoField.GetChunk(photoField.ActualSize), Byte())
                Dim stream As New MemoryStream(data)
                sPhoto = New Bitmap(stream)
                stream.Close()
            End If
            Return sPhoto
        End Get
        Set(ByVal Value As Image)
            Dim photoField As ADODB.Field = Fields("Flag")
            photoField.Value = Nothing
            If Not (Value Is Nothing) Then
                Dim stream As New MemoryStream

                ' A bug in Image.Save means that we can't just call Photo.Save.  If the image
                ' was read previously from a memory stream then it remains attached and
                ' refuses to save to another memory stream without giving a "Cannot access closed stream"
                ' exception.  The workaround is to copy the image to another bitmap and save that
                '
                Dim bm As New Bitmap(Value)
                bm.Save(stream, System.Drawing.Imaging.ImageFormat.Png)
                photoField.AppendChunk(stream.ToArray())
                bm.Dispose()
                stream.Close()
            End If
            If Not IsEditing Then
                Me.Update(False)
            End If
        End Set
    End Property


However when I compile I get the text "System.Drawing.Bitmap" in the column field. All other fields (text and integers) load correctly. What am I doing wrong here?
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Sun Dec 03, 2006 11:34 pm    Post subject: Reply with quote

This is not a VDO problem - but how you have setup your Virtual Tree bindings. You need to change the cell binding for the row/column containing the image to set the ShowPreview property to true and the ShowText property to false. You may also want to modify the PreviewSize property.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
WaqasK



Joined: 21 Oct 2006
Posts: 32

PostPosted: Tue Dec 05, 2006 11:17 am    Post subject: Reply with quote

yeah you're right, I reallt should have put this in the virtual tree boards. Sorry about that. But yeah i was modifying the bindings in code and what you suggested worked fine. Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Data Objects Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group