Page 1 of 1

Converting Data From Blob Table For Display

Posted: Wed Jul 04, 2012 6:25 pm
by JLGDBMD
I am storing jpeg images to a BLOB table in a Valentina DB with a LiveCode Front and the SQL Yoga Library

I can easily retrieve the binary data from the DB BLOB field "GYN_TF" and store it in a variable.

put sqlquery_createObject("GYN_TF") into theQueryA
sqlquery_set theQueryA, "select clause", "GYN_IMAGES"
put "GYN_TF.DBID = $" into theConditions
replace "$" with CaseN in theConditions
sqlquery_set theQueryA, "Conditions", theConditions
sqlquery_retrieveAsArray theQueryA, theDataA
put the result into theError
put the keys of theDataA[1] & cr & theDataA[1]["GYN_IMAGES"] into ImageHold1
delete line 1 of ImageHold1

How do I convert the binary data in the variable ImageHold1 back to an image for display in LiveCode?

Thanks in advance,

Jorge

Re: Converting Data From Blob Table For Display

Posted: Thu Jul 05, 2012 12:16 pm
by Klaus
Hola Jorge,

welcome to the forum! :D

Can't you just:
...
put tBlobDataFromDB into img "your image here"
...
Or:
...
set the text of img "your image here" to tBlobDataFromDB
...
Just guessing, never worked with BLOB data before.

I think this should be exactly like you imported the images into the database,
only the other way round 8)


Best

Klaus

Re: Converting Data From Blob Table For Display

Posted: Fri Jul 06, 2012 3:46 am
by JLGDBMD
Klaus:

Thanks for the reply.

The data that I retrieve from the BLOB fld looks like this and represents the image (excerpt of first 2 lines of the data) -

" ˇÿˇ‡JFIFHHˇ‚§ICC_PROFILEîappl mntrRGB XYZ ŸacspAPPLapplˆ÷”-appldescodscmxVcprt–8wtptrXYZgXYZ0bXYZDrTRCXchadh,bTRCXgTRCXdescGeneric RGB ProfileGeneric RGB Profilemluc..."


I am not sure what function in Live Code to use to process the data and covert it back to an image for display.

Thanks,

Jorge

Re: Converting Data From Blob Table For Display

Posted: Fri Jul 06, 2012 11:16 am
by Klaus
Hola Jorge,

the BLOB data look OK, see the "JFIF" at the beginning?
That's the binary representation of hte JPEG imge, just like what you will see, if you open an image in a TEXT editor.

Did you try my proposals?
That should work!


Best

Klaus

Re: Converting Data From Blob Table For Display

Posted: Sat Jul 07, 2012 3:29 am
by JLGDBMD
Thanks Klaus!

I imported a generic image to use as the test image.

I can change it to whatever image I wish to display by writing the binary text of the image that I retrieved from the DB to it.

Global ImageHold1
set the text of img "TestImage" to ImageHold1
show image "TestImage"

Regards,

Jorge