I convert a bitmap
to jpeg
and want to display the result in the image using different scales. I am using the following code that works great.
procedure TForm1.Button1Click(Sender: TObject);
var
Bmp: TBitmap;
Jpg: TJPEGImage;
begin
Bmp := TBitmap.Create;
Bmp.PixelFormat := pf32bit;
Jpg := TJPEGImage.Create;
try
Bmp.LoadFromFile('0C310060.bmp');
Jpg.Assign(Bmp);
Jpg.SaveToFile('0C310060.jpg');
Image1.Picture.Assign(Jpg);
TJPEGImage(Image1.Picture.Graphic).Scale := jsEighth;
finally
Jpg.Free;
Bmp.Free;
end;
end;
I do not need a file jpeg
on disk. However, if I delete the line Jpg.SaveToFile('0C310060.jpg')
, I get an access violation. Why? What is doing Jpg.SaveToFile
behind the scenes to prevent access violation?
source
share