SQLite Image Insertion/Retrieval

Creating desktop or client-server database solutions?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
Death
Posts: 15
Joined: Thu Oct 19, 2006 5:56 pm

SQLite Image Insertion/Retrieval

Post by Death » Wed Jan 03, 2007 9:59 pm

Hi,

anybody know how to get a picture into and out of AltSQLite?

I would also like to be able to display the images and DB fields in something sort of a portal, like in Filemaker, any ideas?

(for those who wonder what that is: A portal in Filemaker is a scrollable list field which displays fields and/or images from within the DB via a relationship. In my case I just want to know how to do this, don't need the relationship part...)

Thanx in advance fo any help.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5138
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sat Mar 10, 2007 5:45 pm

Hi Death,

It seems that the best way to store an image into aSQL database from Revolution is as a base64 encoded string. I and other have tried storing it directly as binary data, which seems to work fine, but retrieving it appeared to be a big hassle. Once it is base64 encoded, you can treat it like a normal BLOB. Of course, you'll need to find a way to decode it in FileMaker, but I am sure this is not too difficult.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Death
Posts: 15
Joined: Thu Oct 19, 2006 5:56 pm

Post by Death » Sat Mar 10, 2007 6:33 pm

Thanx Mark!

Base64 will blow up the image data by quite a bit, I was hoping that there's a way without having to change the actual image data, bummer...

Any idea on how to display the data (images and text from the database) in a scrollable list?
(I didn't mean to display it in Filemaker, just the same way Filemaker does it). In FM I have no problem (it's built in).

In REV I have no clue on how to display a scrollable list of image and text items, whose size is unknown at run time (i.e. how many lines of data in list). For ex, I want an image field, a text field and so on on the same line in a scrollable list of items.
Any Idea?

I had to go ahead and do the project in FM, since I couldn't figure it out in Rev. I am new to Rev and try to absorb as much info as I can, however the DB and UI limitations have kept me from getting started so far. I hope that some day I actually get to do something in Rev.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5138
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sat Mar 10, 2007 6:55 pm

Hi Death,

You can include images in fields using the imageSource property (check the docs). However, in your case, it would probably be much better to use groups.

First, make a group that contains an image object and a field. Make another group (e.g. by creating a button, grouping it and deleting the button while keeping the group), give the group the size you want and set the lockLoc of the group to true.

Before you retrieve new data, use the copy command to copy the group with the image objects and the field into the second group (copy grp 1 to grp 2). Use a repeat loop to set the rect of all previously copied groups in groups 2. Now set the rect of the last group.

Retrieve your image data, set the imagedata of the new image to the retrieved image data. Retrieve text, put it into the new field. Set the height and width of the copied group such as to make the image and the field fit (use the formattedHeight and formattedWidth properties of the image object and the field).

You can achieve nice effects by setting the hScrollbar and vScrollbar of the main group to true.

Good luck!

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Death
Posts: 15
Joined: Thu Oct 19, 2006 5:56 pm

Post by Death » Sat Mar 10, 2007 7:42 pm

Hi Mark,

You lost me somewhere here...

1. I make 2 groups (Lets call them group A & B.)
, one I setup to hold the image and text fields (group A), the other is an empty group (group B).
Now, which group do I set the lockLoc and size of? A or B?
2. Copy group A to B. Set the rect of all copied groups A in group B. Set them
to what?
3. Set the rect of the last group, which is group A or B?
4. set the height and width of the copied group to the bigger of the image or
text ?
5. The scroll bar of the main group is group B?

Could you elaborate a little more so I can understand what's at work here?
I don't seem to get the whole process, it's Saturay and my brain is already
in weekend mode... :oops:

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5138
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sat Mar 10, 2007 9:35 pm

Hi Death,

1. I make 2 groups (Lets call them group A & B.)
, one I setup to hold the image and text fields (group A), the other is an empty group (group B).
Now, which group do I set the lockLoc and size of? A or B?

You make group B big and set its lockLoc to true.

2. Copy group A to B. Set the rect of all copied groups A in group B. Set them
to what?

Set the rects of groups A, or maybe I should write A1, A2, A3...., such that they fit within group B. For example, you could set the width of all groups A to the width of group B and the top of group A9 to the bottom of group A8 etc (when you start retrieving data from the first record, you only have group A1, which is easy. For the next record, you create group A2 and set its top to the bottom of grp A1 etc).

3. Set the rect of the last group, which is group A or B?

The last group might be group A9. If you decide to set the width of all groups A to the width of group B and the top of group A9 to the bottom of group A8 etc, you will see that all groups are (vertially) on top of each other. Because group B is of limited size, you will see only a few groups. If you set the vScrollbar of group B to true, you can scroll groups A.

4. set the height and width of the copied group to the bigger of the image or
text ?

Yes. If the height of an image is larger than the height of a text, you set the height of group A1 (or A2 etc) to the height of the image. If the text is higher, you set the height of group A1 to the formattedHeight of its text field.

5. The scroll bar of the main group is group B?

yes.

Hope this help.

Mark

P.S. Maybe someone who reads this has too much time on his/her hands and can make an example ;-)
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Death
Posts: 15
Joined: Thu Oct 19, 2006 5:56 pm

Post by Death » Sat Mar 10, 2007 10:01 pm

Ok, I got it, just wasn't sure of the concept initially.

It's a bunch of stacked groups within another larger (rectangle) group which has a scrollbar.

Cool, I am glad I thought of that... (hehe)



Is there a limit on how many of these stacked groups I can put into the larger one (B)?

Which leads to the next question:

What are Revs limits on the various objects and data types?
Is there anything in the manuals specifying those?

Thanx again! U da man! After 3 Month of nobody answering this I gave up, but now I might just revive this for the next project...

Jack

Post Reply

Return to “Databases”