Board index » delphi » D4 - Saving from TImage as JPEG file...

D4 - Saving from TImage as JPEG file...

I have no problems displaying jpg files or for that matter even printing
them is fine.  The problem I'm having is I load a jpg into a TImage using
LoadFromFile than draw some lines, circles, etc on the TImage and want to
resave the image as a jpg.  However, when I use the SaveToFile('MyFile.jpg')
the file is actually a bmp file not a jpg file?

Does anyone know how to accomplish this or is something just not being set
before calling the save?  Any help will be greatly appreciated.

Thanks in advance,

Mike B.

 

Re:D4 - Saving from TImage as JPEG file...


"Mike B." schrieb:

Quote
> I have no problems displaying jpg files or for that matter even printing
> them is fine.  The problem I'm having is I load a jpg into a TImage using
> LoadFromFile than draw some lines, circles, etc on the TImage and want to
> resave the image as a jpg.  However, when I use the SaveToFile('MyFile.jpg')
> the file is actually a bmp file not a jpg file?

> Does anyone know how to accomplish this or is something just not being set
> before calling the save?  Any help will be greatly appreciated.

> Thanks in advance,

> Mike B.

If you draw on TImage, it creates for its Picture- property a TBitmap and draw
the TJpegImage to the Bitmap. TJpegimage is destroyed. You can't draw on  on
TJpegImage. It's only designed to load and save files. Windows needs a Bitmap or
a Metafile to draw. To save after drawing to the TImage, create a TJpegImage and
let the Picture draw to TJpegImage and then save TJPegImage to file.

ciao Andreas

Re:D4 - Saving from TImage as JPEG file...


Thanks for the response Andreas.

Do you have an example that does what you describe in your last sentence?

Thanks again,

Mike B.

Quote
Andreas W?llenstein wrote in message <3796EA17.BC66C...@heitker.de>...

>"Mike B." schrieb:

>> I have no problems displaying jpg files or for that matter even printing
>> them is fine.  The problem I'm having is I load a jpg into a TImage using
>> LoadFromFile than draw some lines, circles, etc on the TImage and want to
>> resave the image as a jpg.  However, when I use the

SaveToFile('MyFile.jpg')
Quote
>> the file is actually a bmp file not a jpg file?

>> Does anyone know how to accomplish this or is something just not being
set
>> before calling the save?  Any help will be greatly appreciated.

>> Thanks in advance,

>> Mike B.

>If you draw on TImage, it creates for its Picture- property a TBitmap and
draw
>the TJpegImage to the Bitmap. TJpegimage is destroyed. You can't draw on
on
>TJpegImage. It's only designed to load and save files. Windows needs a
Bitmap or
>a Metafile to draw. To save after drawing to the TImage, create a
TJpegImage and
>let the Picture draw to TJpegImage and then save TJPegImage to file.

>ciao Andreas

Re:D4 - Saving from TImage as JPEG file...


Try this:

var
     jpeg : TJpegImage;
begin
     jpeg := Tjpegimage.Create;
     jpeg.assign(image1.picture.bitmap);
     jpeg.compress;
     jpeg.savetofile('myimage.jpg');
     jpeg.Free;
end;

Elpidio

Quote
"Mike B." wrote:
> Thanks for the response Andreas.

> Do you have an example that does what you describe in your last sentence?

> Thanks again,

> Mike B.

> Andreas W?llenstein wrote in message <3796EA17.BC66C...@heitker.de>...

> >"Mike B." schrieb:

> >> I have no problems displaying jpg files or for that matter even printing
> >> them is fine.  The problem I'm having is I load a jpg into a TImage using
> >> LoadFromFile than draw some lines, circles, etc on the TImage and want to
> >> resave the image as a jpg.  However, when I use the
> SaveToFile('MyFile.jpg')
> >> the file is actually a bmp file not a jpg file?

> >> Does anyone know how to accomplish this or is something just not being
> set
> >> before calling the save?  Any help will be greatly appreciated.

> >> Thanks in advance,

> >> Mike B.

> >If you draw on TImage, it creates for its Picture- property a TBitmap and
> draw
> >the TJpegImage to the Bitmap. TJpegimage is destroyed. You can't draw on
> on
> >TJpegImage. It's only designed to load and save files. Windows needs a
> Bitmap or
> >a Metafile to draw. To save after drawing to the TImage, create a
> TJpegImage and
> >let the Picture draw to TJpegImage and then save TJPegImage to file.

> >ciao Andreas

Re:D4 - Saving from TImage as JPEG file...


Thanks!

Quote
elp wrote in message <379A23CA.CA1C1...@solos.ufv.br>...
>Try this:

>var
>     jpeg : TJpegImage;
>begin
>     jpeg := Tjpegimage.Create;
>     jpeg.assign(image1.picture.bitmap);
>     jpeg.compress;
>     jpeg.savetofile('myimage.jpg');
>     jpeg.Free;
>end;

>Elpidio

>"Mike B." wrote:

>> Thanks for the response Andreas.

>> Do you have an example that does what you describe in your last sentence?

>> Thanks again,

>> Mike B.

>> Andreas W?llenstein wrote in message <3796EA17.BC66C...@heitker.de>...

>> >"Mike B." schrieb:

>> >> I have no problems displaying jpg files or for that matter even
printing
>> >> them is fine.  The problem I'm having is I load a jpg into a TImage
using
>> >> LoadFromFile than draw some lines, circles, etc on the TImage and want
to
>> >> resave the image as a jpg.  However, when I use the
>> SaveToFile('MyFile.jpg')
>> >> the file is actually a bmp file not a jpg file?

>> >> Does anyone know how to accomplish this or is something just not being
>> set
>> >> before calling the save?  Any help will be greatly appreciated.

>> >> Thanks in advance,

>> >> Mike B.

>> >If you draw on TImage, it creates for its Picture- property a TBitmap
and
>> draw
>> >the TJpegImage to the Bitmap. TJpegimage is destroyed. You can't draw on
>> on
>> >TJpegImage. It's only designed to load and save files. Windows needs a
>> Bitmap or
>> >a Metafile to draw. To save after drawing to the TImage, create a
>> TJpegImage and
>> >let the Picture draw to TJpegImage and then save TJPegImage to file.

>> >ciao Andreas

Other Threads