luistsousa
Technical User
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();
}
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();
}