Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous message
Zbych is currently offline  Zbych
Messages: 326
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

 
Read Message
Read Message
Previous Topic: Another String error solved, maybe.
Next Topic: How do I alpha blend the image?
Goto Forum:
  


Current Time: Sat May 18 02:11:42 CEST 2024

Total time taken to generate the page: 0.01632 seconds