From: "Lemke" Subject: decoding /encoding of Jpeg-Files with TJPEG Date: 03 Mar 2000 00:00:00 GMT Message-ID: <38bf847f@dnews> Sender: "Lemke" X-Trace: 3 Mar 2000 01:23:11 -0800, 207.105.83.65 Reply-To: "Lemke" Newsgroups: borland.public.delphi.graphics X-User-Info: 141.16.180.132 141.16.180.132 I need to read an JpegFile and save it with an changed quality to the disk again. I already find out that I have to assign the jpeg-data to an TBimap-Component and then assigned it back to the TJpeg-Component to save it again with an new Quality. If I do this there is an strange behavior. Problem ist that it works with smal images but if I use larger images (e.g. more than 1 Mb Jpeg-Files) I get some times an Jpeg-Error number 36 but some times not. Is there anybode with know I can solve this problem. next the code I have written: var JPEGImageS: TJPEGImage; BMPImage: TBitmap; procedure TForm1.FormCreate(Sender: TObject); begin BMPImage:= TBitmap.Create; end; procedure TForm1.FormDestroy(Sender: TObject); begin BMPImage.Free; end; procedure TForm1.Button1Click(Sender: TObject); var JPEGImageS: TJPEGImage; begin if OpenDialog1.Execute then begin JPEGImageS:= TJPEGImage.Create; with JPEGImageS do begin LoadFromFile(OpenDialog1.Filename); BMPImage.Width := Width; BMPImage.Height := Height; BMPImage.Canvas.Draw(0,0,JPEGImageS); end; JPEGImageS.free end; end; procedure TForm1.Button2Click(Sender: TObject); begin with TJPEGImage.Create do begin Assign(BMPImage); CompressionQuality:= Trackbar1.Position; Compress; SaveToFile('d:\Test.jpg'); Free; end; end;