Hi All.
I have a JPEG image, which if I convert to bitmap, then back to JPEG again, it
is not the same. The problem occurs in the stretchdraw function.
Can anyone advise how I can replicate exactly the JPEG original without copying
the JPEG original to another JPEG?

What happens is most graphics programs can load the new image, but there is a
difference I cannot ascertain which stuffs up some other graphics programs.
Thanks,
al+

procedure TForm1.btnWriteClick(Sender: TObject);
var Orig,Smaller:tjpegimage;
    buffer:tbitmap;
    smallFname:string;
begin
  smallFname := copy(ImgData.Filename,1,length(ImgData.Filename)-4)
    +'_smaller.jpg';
  JpegOut.FileName := smallFName;
  if not JpegOut.Execute then
    exit;
  SmallFName := JPegOut.FileName;
  Buffer := tbitmap.Create;
  Orig := tjpegImage.Create;
  Smaller := tjpegimage.create;
  try
    Orig.LoadFromFile(ImgData.Filename);
    Orig.DIBNeeded;
    Buffer.PixelFormat := pf24bit;
    Buffer.Width := orig.Width div 2;
    Buffer.Height := orig.Height div 2;
    // Even if the width & height are the same the following does not return a
    //copy of the original JPEG (disregard compression etc)
    Buffer.Canvas.stretchdraw(rect(0,0,Buffer.width,buffer.height),Orig);
    Smaller.PixelFormat:=orig.PixelFormat;
    Smaller.Assign(Buffer);

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to