Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Dec 16, 2017 1:31 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Retrieving a photo from RealSQLDatabase
PostPosted: Thu Apr 25, 2013 1:10 pm 
Offline

Joined: Fri Sep 30, 2005 7:39 pm
Posts: 106
Location: Oklahoma
I have some .jpeg photos stored as binary data string in a REALSQLDatabase. They were put into the database using an RB Desktop App. They are there, and show up using SQLite Manager.

I need to retrieve these photos in a Web App and display in a WebCanvas or WebImageView control.

I can get the binary string out using:
imgData = cur.Field("bin_data").StringValue   //binary picture data

but can't figure out how to get it to display in the WebCanvas or WebImageView.

I have also tried
imgData = cur.Field("bin_data").PictureValue   //binary picture data

but that always gives me an "Unsupported Format Exception"

Anyone have a solution or example code?


Top
 Profile  
Reply with quote  
 Post subject: Re: Retrieving a photo from RealSQLDatabase
PostPosted: Thu Apr 25, 2013 1:16 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
You can use the Picture.FromData to convert raw binary data into a Picture object:
imgData = cur.Field("bin_data").StringValue
Dim Pic As Picture = Picture.FromData(imgData)

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: Retrieving a photo from RealSQLDatabase
PostPosted: Thu Apr 25, 2013 2:37 pm 
Offline

Joined: Fri Sep 30, 2005 7:39 pm
Posts: 106
Location: Oklahoma
Charonn0-

Thanks. This also gives me an "Unsupported Format Exception"

Is there a difference in the binary format of a Desktop App picture stored in the database and the binary format that a Web App needs to retrieve it?

The photos are dragged and dropped to a canvas in the Desktop Application. Scaled to size, and then assigned to a Desktop Canvas backdrop. In a Save pushbutton, the Canvas.Backdrop is saved to the database using Bailey's PictureToString function.

In the Desktop app, I can retrieve the pictures using Bailey's StringToPicture function just fine.

But in the Web app, I keep getting the Format Exception. There must be a step I'm missing that converts the desktop binary string into something that the web app can use. Any Idea?


Top
 Profile  
Reply with quote  
 Post subject: Re: Retrieving a photo from RealSQLDatabase
PostPosted: Thu Apr 25, 2013 3:11 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
I'm not familiar with Bailey's PictureToString function. My suggestion relies on the binary data being manipulated being the raw binary picture data, such as that returned by the built-in Picture.GetData function.

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: Retrieving a photo from RealSQLDatabase
PostPosted: Thu Apr 25, 2013 5:57 pm 
Offline

Joined: Fri Sep 30, 2005 7:39 pm
Posts: 106
Location: Oklahoma
I think it's Mike Bailey, Database Tip #11 , and in several other forum entries I've studied.

It seems to work great from a Desktop App, but I can't seem to retrieve the photo using a Web App.

This gives unsupported format exception, probably because Web Apps use WebPicture instead of just Picture:
imgData = cur.Field("bin_data").StringValue
Dim Pic As Picture = Picture.FromData(imgData)


When I change the dim to WebPicture like this:
imgData = cur.Field("bin_data").StringValue
Dim Pic As WebPicture = WebPicture.FromData(imgData)


Rb complans that "FromData" doesn't exist.

I'll see what I can do with Picture.GetData.

Thanks.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group