Board index » cppbuilder » Repost: TBitmap::SaveToFile creates modified image

Repost: TBitmap::SaveToFile creates modified image

Hi!
I have a problem saving TBitmap object with SaveToFile().
Drawing my TBitmap displays the image right. But when I save it using
SaveToFile() it creates a very strange .bmp file. It looks like the image
was split into to parts which changed their positions with each other.
Besides the colors of the image are changed.
If it may help I actially get this TBitmap by reading from a Paradox
database using BDE.
Here is what i do:

Graphics::TBitmap *Bitmap = new Graphics::TBitmap();
Bitmap->Assign(Table1->FieldByName("Picture"));
Bitmap->SaveToFile("file.bmp");
delete Bitmap;

Thanks!

 

Re:Repost: TBitmap::SaveToFile creates modified image


Hi Dima,

Quote
> I have a problem saving TBitmap object with SaveToFile().
> Drawing my TBitmap displays the image right.

Try BitBlt()ing the Bitmap to the screen, and verify that it indeed displays
correctly.  If it does, you can capture the screen to get the image, or manually
fill in the BITMAPFILEHEADER structure which seems to be corrupted by the
SaveToFile() method.  You may also have better luck using the TDBImage
component.

Good luck.

--------------------------------------
Damon Chandler

http://bcbcaq.freeservers.com
Answers to <Commonly Asked Questions>

Re:Repost: TBitmap::SaveToFile creates modified image


Dima Vukolov skrev i meddelelsen <7pphlt$d...@forums.borland.com>...

Quote
>Hi!
>I have a problem saving TBitmap object with SaveToFile().
>Drawing my TBitmap displays the image right. But when I save it using
>SaveToFile() it creates a very strange .bmp file. It looks like the image
>was split into to parts which changed their positions with each other.
>Besides the colors of the image are changed.
>If it may help I actially get this TBitmap by reading from a Paradox
>database using BDE.
>Here is what i do:

>Graphics::TBitmap *Bitmap = new Graphics::TBitmap();
>Bitmap->Assign(Table1->FieldByName("Picture"));
>Bitmap->SaveToFile("file.bmp");
>delete Bitmap;

>Thanks!

In sted og generating a bitmap, you can load one.
When you create your form, you just have to put on a canvas and then load a
.bmp file to this.
The bitmap must have the same size and number og color as the result shut
have.

That shoult fix the problem - but i't make's the program a bit bigger.

Christian Kold

Other Threads