Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"bitmap image is not valid"

Status
Not open for further replies.

luistsousa

Technical User
May 12, 2003
66
PT
Hello

I pretend to have a database with a blob field ( image_field) to save bmp images,and to convert this bmp pictures to a jpeg pictures in database. The problem is that appear a error message "bitmap image is not valid".
How can i correct this problem? The code is in down.

Many thanks



if (OpenPictureDialog1->Execute()){

std::auto_ptr<Graphics::TBitmap> bitmap(new Graphics::TBitmap);
bitmap->LoadFromFile(OpenPictureDialog1->FileName);
std::auto_ptr<TJPEGImage> jpeg(new TJPEGImage);
jpeg->Assign(bitmap.get());
std::auto_ptr<TMemoryStream> stream (new TMemoryStream);
jpeg->SaveToStream(stream.get());
stream->Position = 0;
DataModule1->Table1->Append();
DataModule1->Table1image_field ->LoadFromStream(stream.get());
DataModule1->Table1->Post();
}
 
Hi

You can try something like

DataModule1->Table1->Append();
((TBlobField *)DataModule1->Table1->FieldByName(&quot;image_field&quot;))->LoadFromFile(OpenPictureDialog1->FileName);
DataModule1->Table1->Post;

or if it's a persistant field, like in your case then try

DataModule1->Table1->Append();
DataModule1->Table1image_field->LoadFromFile(OpenPictureDialog1->FileName);
DataModule1->Table1->Append();

That should help :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top