Serializing Image Data, Reporting, Etc


Author
Message
Jerome Barnett
Jerome Barnett
StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)
Group: Forum Members
Posts: 10, Visits: 65
I'm new to serialization but I think I may have discovered an issue with generically serializing Image objects. (Then again it could all be in my head)



I have images which I am scanning into a System.Drawing.Image object and then saving into an Image column in a SQL 2005 DB.

Reading and writing the images works great...until...I started using Crystal Reports with my app and the Image fields in my report would all be blank.



I did some trouble shooting and the only thing I could do to get it working was to change the property setter/getter for my image columns in my BO class.

(I also had to rescan my images, but it's a new app, so no biggie)



I changed the property definition to the following.



Public Property [InsCardFront]() As System.Drawing.Image

Get

Try

Dim loStream As New MemoryStream()

loStream.Write(CType(CurrentRow.Item("InsCardFront"), Byte()), 0, CType(CurrentRow.Item("InsCardFront"), Byte()).Length)

Return System.Drawing.Image.FromStream(loStream, True)

Catch

Return Nothing

End Try

End Get

Set(ByVal value As System.Drawing.Image)

Dim loStream As New MemoryStream()

value.Save(loStream, System.Drawing.Imaging.ImageFormat.Jpeg)

Me.CurrentRow.Item("InsCardFront") = loStream.ToArray()

End Set

End Property




It seems that when you serialize an Image object you get more than just image data and that is all that Crystal reports is looking for.



Could someone who knows a little more about serialization correct or inform me if I'm right in thinking this.



If I am right then would it be possible to add an 'Image' option to the BO designer which would change the generated code to something like the above?

It seems that storing the generic image data would be more desirable/flexible than storing a .NET Image object.



Let me know.



Thanks



Jerome
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search