Board index » delphi » Drawing JPEG image

Drawing JPEG image

Hi,

I have a simple problem....
I tryed to draw a JPG image (with compression quality change)  but it does
not work. The image is that is shown
is not compressed

Here is the code:

procedure TJPEGSettingsForm.RefreshJPEGImage;
 var JPGImg : TJPEGImage;

begin

 JPGImg:=TJPEGImage.Create;
 JPGImg.CompressionQuality:=50;
 JPGImg.Grayscale:=True;
 JPGImg.PixelFormat:=jf8Bit;
 JPGImg.Assign(orgImage.Picture.Bitmap);
 JPGImg.Compress;

 compImage.Canvas.Draw(0, 0, JPGImg);
 compImage.Refresh;
 JPGImg.Free;
end;

---------

Thanks.

 

Re:Drawing JPEG image


Quote
Matej Sekoranja wrote in message <7c17c5$em...@forums.borland.com>...
>I have a simple problem....
>I tryed to draw a JPG image (with compression quality change)  but it does
>not work. The image is that is shown
>is not compressed

I don't remember the details, but the code in my BMPJPG Lab Report does:
www.efg2.com/lab/Graphics/BMPJPG.htm

efg
_________________________________
efg's Computer Lab:       www.efg2.com/lab
Delphi Books:  www.efg2.com/lab/TechBooks/Delphi.htm

Earl F. Glynn     E-Mail:  EarlGl...@att.net
Overland Park, KS  USA

Re:Drawing JPEG image


On Mon, 8 Mar 1999 20:13:54 +0100, "Matej Sekoranja"

Quote
<matej.sekora...@writeme.com> wrote:
>Hi,

>I have a simple problem....
>I tryed to draw a JPG image (with compression quality change)  but it does
>not work. The image is that is shown
>is not compressed

>Here is the code:

>procedure TJPEGSettingsForm.RefreshJPEGImage;
> var JPGImg : TJPEGImage;

>begin

> JPGImg:=TJPEGImage.Create;
> JPGImg.CompressionQuality:=50;
> JPGImg.Grayscale:=True;
> JPGImg.PixelFormat:=jf8Bit;
> JPGImg.Assign(orgImage.Picture.Bitmap);
> JPGImg.Compress;

> compImage.Canvas.Draw(0, 0, JPGImg);
> compImage.Refresh;
> JPGImg.Free;
>end;

>---------

>Thanks.

I am not 100% sure, but I am pretty sure that CompressionQuality only
effects the output of a JPEG to a file.  You might try saving the file
and then reloading it.  I am sure someone else may have a more
efficient method however.

Re:Drawing JPEG image


My experience has been that the image is loaded into a dib somehow and never
gets compressed until you tell it to savetofile or savetostream. If you finger
out how to do it let me know too :)
Davie
Quote
Matej Sekoranja wrote:
> Hi,

> I have a simple problem....
> I tryed to draw a JPG image (with compression quality change)  but it does
> not work. The image is that is shown
> is not compressed

> Here is the code:

> procedure TJPEGSettingsForm.RefreshJPEGImage;
>  var JPGImg : TJPEGImage;

> begin

>  JPGImg:=TJPEGImage.Create;
>  JPGImg.CompressionQuality:=50;
>  JPGImg.Grayscale:=True;
>  JPGImg.PixelFormat:=jf8Bit;
>  JPGImg.Assign(orgImage.Picture.Bitmap);
>  JPGImg.Compress;

>  compImage.Canvas.Draw(0, 0, JPGImg);
>  compImage.Refresh;
>  JPGImg.Free;
> end;

> ---------

> Thanks.

Other Threads