Extracting images(blobs) from SQLite

Hello!
I have a problem. My SQLite contains images in a blob, but I can’t extract this images and put them in “display” object type.
This code didn’t work:

local i = 1;  
for row in db:nrows("SELECT \* FROM images") do  
  
 Img[i] = display.newImageRect(row.image, \_W\*0.66, \_H\*0.5);  
 Img[i]:setReferencePoint(display.CenterReferencePoint);  
 i = i+1;  
end  

I’ve got the WARNING message: “failed to find image ( )”
This is because the display images can be loaded only from file and function tryed to find the path instead of loading from database.

I can’t imagine how take images from database and convert it to “display objects”.

Is this possible?

Please help!
Sorry for my English.
[import]uid: 106224 topic_id: 31283 reply_id: 331283[/import]

Don’t think it is possible in Corona.
Maybe you should write the image to a file first and then load it with display.newImageRect() [import]uid: 138389 topic_id: 31283 reply_id: 125068[/import]

If you really needd the images in a database then vovasoft told you the wrote that would be best to take. Anytime i’ve had images in databases i had to get the data via a memory stream as opposed to select myimage from images.

The real question is, however, is why the heck do you need your images in the database? Why not just a reference to the images file path instead? [import]uid: 147305 topic_id: 31283 reply_id: 125075[/import]

Hello. Ok, I’ve got it. Thanks!

My purpose is a storing data related to images such as: name of image, number and other information.
I thought about all this stuff and I think to do the next thing:
the name of the image will be the same as a value of ‘id’ field of the row related to this image in database. This provides me connection I need

Do you like my approach or maybe you can suggest more elegant way of solving this issue? [import]uid: 106224 topic_id: 31283 reply_id: 125111[/import]

Seems pretty close to what I would do. In a normal environment my ‘id’ field would be a more normal primary key(like a number) but it probably doesn’t matter for your case. [import]uid: 147305 topic_id: 31283 reply_id: 125126[/import]

It seems pretty good for me too. I don’t see any reasons why not. If I want a name of the card I can get it from db by this id matching [import]uid: 106224 topic_id: 31283 reply_id: 125145[/import]

Don’t think it is possible in Corona.
Maybe you should write the image to a file first and then load it with display.newImageRect() [import]uid: 138389 topic_id: 31283 reply_id: 125068[/import]

If you really needd the images in a database then vovasoft told you the wrote that would be best to take. Anytime i’ve had images in databases i had to get the data via a memory stream as opposed to select myimage from images.

The real question is, however, is why the heck do you need your images in the database? Why not just a reference to the images file path instead? [import]uid: 147305 topic_id: 31283 reply_id: 125075[/import]

Hello. Ok, I’ve got it. Thanks!

My purpose is a storing data related to images such as: name of image, number and other information.
I thought about all this stuff and I think to do the next thing:
the name of the image will be the same as a value of ‘id’ field of the row related to this image in database. This provides me connection I need

Do you like my approach or maybe you can suggest more elegant way of solving this issue? [import]uid: 106224 topic_id: 31283 reply_id: 125111[/import]

Seems pretty close to what I would do. In a normal environment my ‘id’ field would be a more normal primary key(like a number) but it probably doesn’t matter for your case. [import]uid: 147305 topic_id: 31283 reply_id: 125126[/import]

It seems pretty good for me too. I don’t see any reasons why not. If I want a name of the card I can get it from db by this id matching [import]uid: 106224 topic_id: 31283 reply_id: 125145[/import]