Hello
In Delphi 10.4, VCL :
Is it possible to use the TAdvPicture to convert an image to a valid JPEG ?
I have a picture which raises an error :"jpeg error #53" when I try to assign it to a bitmap, jpeg, image.
But, the TAdvPicture-component shows it without any problem.
So, this works :
AdvPicture1.Picture.LoadFromFile( 'bloem.jpg' ) ;
But I cannot save/convert the image to a valid JPEG
This is what I raises the error :
procedure TForm1.Button3Click(Sender: TObject);
var
Graphic : TGraphic ;
vPic : TPicture;
begin
Graphic := TJPEGImage.Create ;
Graphic.LoadFromFile('bloem.jpg' );
// ----> ... raised exception class EJPEG with message 'JPEG error #53'
end;
This also rasises the same error:
procedure TForm1.Button1Click(Sender: TObject);
var
JPEG : TJPEGImage ;
begin
JPEG := TJPEGImage.Create ;
JPEG.LoadFromFile( 'bloem.jpg' ) ;
// --> raised exception class EJPEG with message 'JPEG error #53'*
I tried to save the loadedimage to a file first :
AdvPicture1.Picture.SaveToFile('advPicture.jpeg') ;
but without any result ..
Finaly, I managed to show the picture in a TImage as follows :
procedure TForm1.bbAdv2JpegClick(Sender: TObject);
var
JPEG : TJPEGImage ;
memStream : TMemoryStream ;
bm: TBitMap ;
begin
JPEG := TJPEGImage.Create ;
memStream :=TMemoryStream.Create ;
memStream.Position := 0 ;
AdvPicture1.Picture.LoadFromFile( 'bloem.jpg' ) ;
AdvPicture1.Picture.SaveToStream( memStream ) ;
memStream.Position := 0 ;
bm := VCL.Graphics.TBitmap.Create ;
bm.LoadFromStream( memstream ) ;
image1.Picture.Bitmap.Assign( bm ) ;
image1.Picture.SaveToFile('Adv2JPEG.JPEG') ;
RotateImage1.Picture.LoadFromFile('Adv2JPEG.JPEG') ;
// --> raised exception class EJPEG with message 'JPEG error #53'*
I searched for "TAdvPicture" but did not get any results...
any hints are welcome !
kind regards,
Dirk Janssens.