Re:Drawing on JPEG Image
Quote
Michael Warner wrote:
> I've just installed TJPEG for BCB3, and it's loading JPEGs into a
> TImage correctly. However, in my app I need to subsequently draw on
> the TImage, and this no longer works, since the image isn't a bitmap.
> Is there a simple way to convert the loaded JPEG to a bitmap, either
> in-place or to another TImage etc?
There may be a better way, and if there is, I'd love to hear about it. The
Bitmap property of TJPEGImage is protected. The JPEG is rendered on
the bitmap canvas. To convert the bitmap back to JPEG, you need to call
Compress(). I've resorted to this ugliness in the past:
In the header:
class THackedJPEGImage:public TJPEGImage
{
friend class TForm1;
In the source:
((THackedJPEGImage*)(Image1->Picture->Graphic))->Bitmap->
Canvas->Rectangle(10, 10, 30,
30);
Image1->Refresh();
((TJPEGImage *)Image1->Picture->Graphic)->Compress();
Image1->Picture->SaveToFile("c:\\test.jpg");
I wasn't sure if you wanted to save the altered TImage.
I guess maybe you could publish the read-only Bitmap property in a derived
class or something.