New topic: 

Retrieving a photo from RealSQLDatabase

<http://forums.realsoftware.com/viewtopic.php?t=47703>

         Page 1 of 1
   [ 5 posts ]                 Previous topic | Next topic          Author  
Message        RobertLob          Post subject: Retrieving a photo from 
RealSQLDatabasePosted: Thu Apr 25, 2013 1:10 pm                         
Joined: Fri Sep 30, 2005 7:39 pm
Posts: 103
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                charonn0          Post subject: 
Re: Retrieving a photo from RealSQLDatabasePosted: Thu Apr 25, 2013 1:16 pm     
                            
Joined: Mon Apr 02, 2007 2:08 am
Posts: 1201
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                RobertLob          Post 
subject: Re: Retrieving a photo from RealSQLDatabasePosted: Thu Apr 25, 2013 
2:37 pm                         
Joined: Fri Sep 30, 2005 7:39 pm
Posts: 103
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                charonn0          Post subject: 
Re: Retrieving a photo from RealSQLDatabasePosted: Thu Apr 25, 2013 3:11 pm     
                            
Joined: Mon Apr 02, 2007 2:08 am
Posts: 1201
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                RobertLob          Post 
subject: Re: Retrieving a photo from RealSQLDatabasePosted: Thu Apr 25, 2013 
5:57 pm                         
Joined: Fri Sep 30, 2005 7:39 pm
Posts: 103
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             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 5 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to