Home » Community » Newbie corner » Image to an SQLite blob windows 10 (Needcode to load an image froma file to an sqlite blob)
Re: Image to an SQLite blob windows 10 [message #46928 is a reply to message #46924] |
Sun, 18 September 2016 22:40  |
Zbych
Messages: 327 Registered: July 2009
|
Senior Member |
|
|
I haven't done this in sqlite, but in postgres and it was quite easy:
Saving image to database:
//Database.sch
TABLE_ (TABLE_NAME)
SERIAL_ (SOME_ID) PRIMARY_KEY
BLOB_ (COLUMN_NAME)
END_TABLE
//code
Image img;
JPGEncoder jpg(90);
try{
SQL & SqlInsert(TABLE_NAME)
(COLUMN_NAME, SqlBinary(jpg.SaveString(img)))
}catch...
Loading it back:
try{
SQL & SqlSelect(COLUMN_NAME).From(TABLE_NAME).Where(......).Limit(1);
if (SQL.Fetch()){
Image img = StreamRaster::LoadStringAny(SQL[COLUMN_NAME]);
//Use StaticImage to show your image on a screen
}
}catch....
[Updated on: Sun, 18 September 2016 22:59] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Thu May 01 16:18:26 CEST 2025
Total time taken to generate the page: 0.03592 seconds
|