A JPEG file usually uses a compression algorithm that is not losses, meaning, when you reconstruct the bitmap from a JPEG file it is different from the original bitmap from which the JPEG was created. This is done so as to achieve compression rates that are higher than loss-less compression algorithms. The reconstructed image is only visually similar to the original. Because of this, is not possible for you to convert a JPEF to bitmap and them back to a JPEG without any loss of quality. The JPEG format should be used as the final storage / transmission (eg. for web sites) format. If you intend to do any processing on the image, then a loss-less format, such as LZW compressed tiff should be used instead.
Dennis. ----- Original Message ----- From: "Alistair George" <[EMAIL PROTECTED]> To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]> Sent: Thursday, March 20, 2003 12:02 PM Subject: [DUG]: Graphics problems > 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/ > --------------------------------------------------------------------------- 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/