Link to home
Start Free TrialLog in
Avatar of LeTay
LeTay

asked on

How to copy TJPEGImage

In Delphi, how can I copy the image from one TJPEGImage to another ?
Example, I have this
var
 A,B:TJPEGImage;
.../...
begin
.../...
// A has been loaded somewhere and how I want to copy the image to B
Avatar of Ephraim Wangoya
Ephraim Wangoya
Flag of United States of America image

Assign it to B

B.Assign(A)
Avatar of LeTay
LeTay

ASKER

Will the assign really copy the data or just give a pointer ?
I need the data to be copied...
This comment line is taken from source of jpeg and give answer to upper question:
// FImage is shared if Assign is used to copy between TJPEGImage instances

Simply create new intermediate bitmap and do assign with it:

...
var
  jpg2: TJPEGImage;
  Bmp: TBitmap;
begin
  jpg2 := TJPEGImage.Create;
  Bmp := TBitmap.Create;
  Bmp.Assign(Jpg1);
  Jpg2.Assign(Bmp);
....
  Bmp.Free;
  jpg2.Free;
...

Open in new window

Avatar of LeTay

ASKER

Just using Assign crashed my exe (access violation)
The TJPEGImage B (destinator) is inside a DLL ...
Avatar of LeTay

ASKER

Isnt' there a way to copy the picture from one TJPEGImage to another using a TMemoryStream and, if yes, how ?
Thanks
ASKER CERTIFIED SOLUTION
Avatar of Sinisa Vuk
Sinisa Vuk
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial