Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Loading PNG image file saved in BLOB to TPicture
Mon, Nov 14 2011 10:37 PMPermanent Link

IQA

Hi Tim,

This might be an easily answered question, but I'm getting stumped as to the best way to acheive this.

I have PNG files saved in BLOB fields and want to load a particular blob into a component that uses TPicture to display the image.

I'm using C++ Builder.

If anyone has a good approach please let me know,

Thanks,

Phil.
Mon, Nov 14 2011 11:00 PMPermanent Link

IQA

It's OK... I worked out how to do it after some more testing.... If it's useful to anyone else here's the code (imagedata in the QUERY is a BLOB field storing PNG images):

TEDBBlobStream *BlobStream;
TPngImage *mypng = new TPngImage;

TEDBQuery * GetImageQuery = new TEDBQuery(NULL);
GetImageQuery->DatabaseName = "EDB";
GetImageQuery->SessionName = "EDSSession";

GetImageQuery->SQL->Clear();
GetImageQuery->SQL->Add("SELECT imagedata FROM styleimages WHERE imageID = 1");
GetImageQuery->ExecSQL();

BlobStream = new TEDBBlobStream((TBlobField *)GetImageQuery->FieldByName("imagedata"),bmRead);
mypng->LoadFromStream(BlobStream);
MyBlock->Picture->Assign(mypng);

delete BlobStream, mypng, GetImageQuery;
Tue, Nov 15 2011 2:16 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Philip,

Thanks for sharing.

--
Fernando Dias
[Team Elevate]
Image