In my quest to move to Xojo 2018, I have encountered the following issue with the following code for mImage as Picture:
[code]Dim a as string = rs.Field(“Picture”).StringValue
a = DecodeHex(a)
mImage = Picture.FromData(a)
If(mImage <> Nil) then
Graphics.DrawPicture(mImage,Canvas1.Left,Canvas1.Top,Canvas1.Width,Canvas1.Height,0,0,mImage.Width,mImage.Height)
end if
[/code]
mImage remains Nil in Xojo 2018.
What is the appropriate way to code this in the Xojo 2018?
can you attribute this directly to 2018? (as in does it work in a previous version of Xojo?)
if not, are you sure the you properly encoded the picture, and that it wasn’t altered due to text encoding (UTF-8 etc)?
Are you sure that “a” actually has a value, and that value hasn’t been truncated for example?
[quote=389493:@Dave S]
can you attribute this directly to 2018? (as in does it work in a previous version of Xojo?)
if not, are you sure the you properly encoded the picture, and that it wasn’t altered due to text encoding (UTF-8 etc)?
Are you sure that “a” actually has a value, and that value hasn’t been truncated for example?[/quote]
I am running this on the same database, same record using Xojo 2013 r3.3 and Xojo 2018 r1. The value for mImage in 2018 is Nil and displays the image in 2013.
When I inspect the string value of ‘a’ as text in Xojo 2013, I get the following information:
Not sure exactly why, but the reverse procedure used to store the image is not working correctly in Xojo 2018 but works in Xojo 2013:
Dim mb As MemoryBlock
If mImage <> Nil Then
// Get the image data
mb = "\\x"+EncodeHex(mImage.GetData(Picture.FormatJPEG, Picture.QualityHigh))
rs.Field("picture").Value = mb
End If
Upon working with this data a little longer, I find some interesting and strange behavior.
The image stored with Xojo 2013 but read with Xojo 2018 needs this line commented out:
a = DecodeHex(a)
but if the image is stored using Xojo 2018, then the image cannot be viewed using Xojo 2018 unless the above line is active.
If the image is stored using Xojo 2018 and then retrieved from the database using Xojo 2013, it seems that the Hex data is retrieved correctly however DecodeHex appears to decode the hex code into proper hex code, so if you run DecodeHex two times using Xojo 2013, the photo can be viewed.