Converting Data From Blob Table For Display

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
JLGDBMD
Posts: 12
Joined: Wed Jul 04, 2012 6:13 pm

Converting Data From Blob Table For Display

Post by JLGDBMD » Wed Jul 04, 2012 6:25 pm

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

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Converting Data From Blob Table For Display

Post by Klaus » Thu Jul 05, 2012 12:16 pm

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

JLGDBMD
Posts: 12
Joined: Wed Jul 04, 2012 6:13 pm

Re: Converting Data From Blob Table For Display

Post by JLGDBMD » Fri Jul 06, 2012 3:46 am

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

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Converting Data From Blob Table For Display

Post by Klaus » Fri Jul 06, 2012 11:16 am

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

JLGDBMD
Posts: 12
Joined: Wed Jul 04, 2012 6:13 pm

Re: Converting Data From Blob Table For Display

Post by JLGDBMD » Sat Jul 07, 2012 3:29 am

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

Post Reply