How to Store IMAGES in SQLite in CORONA SDK

Hello awesome CORONA developers!

I am making a game that uses lots of images. Im using Sqlite as my
“database”. I would like to know how I can save images to a database so i
can call/retrieve them whenever i want.

~Do i save the “image path” instead in the sqlite and store the
actual images in a different folder??? Please help me. Im loving corona
so much I wanna bcome a pro dev someday.

SHOW EXAMPLES(that stores at least 2-3 images) if u may…thank you!

MORE POWER CORONA!

I think most people do what you suggested. ie store image path & name and then keep the image files out of the db. The SQLite supports storing images as BLOB data type but I have not seen a sample yet doing this in Corona SDK. The following article provides some insight on the native coding front. 

http://www.iphonesdkarticles.com/2009/02/sqlite-tutorial-saving-images-in.html

ok thanks ksan…appreciate your coming here to answer my question… i guess ill be stickin with my old-fashioned way, or maybe i should start reading about BLOB.  …  :)) CHEEERS!

No worries. I too would love to see a pros / cons evaluation of both options. It would be nice to write the same app using both approaches and then analyse performance & memory footprint etc given difference image file sizes, numbers etc. 

Personally I never saw the value of putting large binary data in the database.  It seems more efficient to keep those files on the filesystem and only store references to the files in the database.  Databases tend to not resize smaller when you remove data from them, so your database file would just grow and grow.

thanks ROB! ill keep my old-fashioned way then :))  - just sage the “image path” to dbase.

We are using “Mobile Atlas Creator” that generate offline map stored as tile in an SQLITE database. Those tiles are stored as PNG in blob data. 

How do we get those images from Blob data from SQLITE with Corona as we did not find any example of way of doing this.

Thanks for your help

I don’t know of a way to take binary data and turn it into an image texture.  It pretty much as to use display.newImage() or display.newImageRect(), but I’ll pass this on to see if it’s something that could make it to Graphics 2.0.

Thanks, as this is pretty much key for us for our tourism application for Quebec province. Any update, news you can provide, will be very welcome.

Right now, you can take your blob, write it out to a temp file with a .png extension (if it’s png data) and then use display.newImageRect()/display.newImage to read it back in.  I still think you’re better off having a bunch of files on the file system and have references to them in the database.

@Rob, I agree with you to store files is a better solution than having them in the database, but in this case, we do not control this, as this is automatically generated by the tool with  GPS reference for each tile. We will build our own tool to extract the files, so we do not need a method to extract the files from the DB.

Thanks for help.

I think most people do what you suggested. ie store image path & name and then keep the image files out of the db. The SQLite supports storing images as BLOB data type but I have not seen a sample yet doing this in Corona SDK. The following article provides some insight on the native coding front. 

http://www.iphonesdkarticles.com/2009/02/sqlite-tutorial-saving-images-in.html

ok thanks ksan…appreciate your coming here to answer my question… i guess ill be stickin with my old-fashioned way, or maybe i should start reading about BLOB.  …  :)) CHEEERS!

No worries. I too would love to see a pros / cons evaluation of both options. It would be nice to write the same app using both approaches and then analyse performance & memory footprint etc given difference image file sizes, numbers etc. 

Personally I never saw the value of putting large binary data in the database.  It seems more efficient to keep those files on the filesystem and only store references to the files in the database.  Databases tend to not resize smaller when you remove data from them, so your database file would just grow and grow.

thanks ROB! ill keep my old-fashioned way then :))  - just sage the “image path” to dbase.

We are using “Mobile Atlas Creator” that generate offline map stored as tile in an SQLITE database. Those tiles are stored as PNG in blob data. 

How do we get those images from Blob data from SQLITE with Corona as we did not find any example of way of doing this.

Thanks for your help

I don’t know of a way to take binary data and turn it into an image texture.  It pretty much as to use display.newImage() or display.newImageRect(), but I’ll pass this on to see if it’s something that could make it to Graphics 2.0.

Thanks, as this is pretty much key for us for our tourism application for Quebec province. Any update, news you can provide, will be very welcome.

Right now, you can take your blob, write it out to a temp file with a .png extension (if it’s png data) and then use display.newImageRect()/display.newImage to read it back in.  I still think you’re better off having a bunch of files on the file system and have references to them in the database.