﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Business Objects and Data Access (How do I?)  » Serializing Image Data, Reporting, Etc</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Sun, 13 Sep 2026 10:51:13 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Serializing Image Data, Reporting, Etc</title><link>http://forum.strataframe.net/FindPost8416.aspx</link><description>I'm not exactly sure what Crystal Reports is expecting, but if they're expecting just raw data for the image, then you can just return the byte array out of the field.&amp;nbsp; Then, just add a custom field with the code that you entered that would call .Save(Jpeg) on the image.&amp;nbsp; However, if Crystal is expecting a System.Drawing.Image object, then both methods will work equally well.&amp;nbsp; The serialized version will take up a bit more space in the database because it's not forcing the file to JPEG format, and it's also storing the extra stuff from the serialization context, but both versions of code return a System.Drawing.Image object, so they are roughly equivalent.&amp;nbsp; &lt;/P&gt;&lt;P&gt;I think your best bet would be to either use the custom code functionality and use the code that you specified, or leave the field as a Byte[] and create a custom property that would save the raw image data in the format that you specify.</description><pubDate>Mon, 23 Apr 2007 09:02:09 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>Serializing Image Data, Reporting, Etc</title><link>http://forum.strataframe.net/FindPost8388.aspx</link><description>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)&lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
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.&lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
(I also had to rescan my images, but it's a new app, so no biggie)&lt;br&gt;
&lt;br&gt;
I changed the property definition to the following.&lt;br&gt;
[quote]&lt;br&gt;
[codesnippet]    Public Property [InsCardFront]() As System.Drawing.Image&lt;br&gt;
        Get&lt;br&gt;
            Try&lt;br&gt;
                Dim loStream As New MemoryStream()&lt;br&gt;
                loStream.Write(CType(CurrentRow.Item("InsCardFront"), Byte()), 0, CType(CurrentRow.Item("InsCardFront"), Byte()).Length)&lt;br&gt;
                Return System.Drawing.Image.FromStream(loStream, True)&lt;br&gt;
            Catch&lt;br&gt;
                Return Nothing&lt;br&gt;
            End Try&lt;br&gt;
        End Get&lt;br&gt;
        Set(ByVal value As System.Drawing.Image)&lt;br&gt;
            Dim loStream As New MemoryStream()&lt;br&gt;
            value.Save(loStream, System.Drawing.Imaging.ImageFormat.Jpeg)&lt;br&gt;
            Me.CurrentRow.Item("InsCardFront") = loStream.ToArray()&lt;br&gt;
        End Set&lt;br&gt;
    End Property[/codesnippet][/quote]&lt;br&gt;
&lt;br&gt;
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.&lt;br&gt;
&lt;br&gt;
Could someone who knows a little more about serialization correct or inform me if I'm right in thinking this.&lt;br&gt;
&lt;br&gt;
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?&lt;br&gt;
It seems that storing the generic image data would be more desirable/flexible than storing a .NET Image object.&lt;br&gt;
&lt;br&gt;
Let me know.&lt;br&gt;
&lt;br&gt;
Thanks&lt;br&gt;
&lt;br&gt;
Jerome</description><pubDate>Mon, 23 Apr 2007 09:02:09 GMT</pubDate><dc:creator>Jerome Barnett</dc:creator></item><item><title>RE: Serializing Image Data, Reporting, Etc</title><link>http://forum.strataframe.net/FindPost8389.aspx</link><description>Here's the original generated code...&lt;br&gt;
&lt;br&gt;
[quote][codesnippet]    Public Property [InsCardFront]() As System.Drawing.Image&lt;br&gt;
        Get&lt;br&gt;
            Try&lt;br&gt;
                Return CType(Me.BinaryFormatter.Deserialize(New MemoryStream(CType(CurrentRow.Item("InsCardFront"), Byte()))), System.Drawing.Image)&lt;br&gt;
            Catch&lt;br&gt;
                Return Nothing&lt;br&gt;
            End Try&lt;br&gt;
        End Get&lt;br&gt;
        Set(ByVal value As System.Drawing.Image)&lt;br&gt;
            Dim loStream As New MemoryStream()&lt;br&gt;
            Me.BinaryFormatter.Serialize(loStream, value)&lt;br&gt;
            Me.CurrentRow.Item("InsCardFront") = loStream.ToArray()&lt;br&gt;
        End Set&lt;br&gt;
    End Property[/codesnippet][/quote]</description><pubDate>Fri, 20 Apr 2007 17:38:29 GMT</pubDate><dc:creator>Jerome Barnett</dc:creator></item></channel></rss>