Hi Everyone,
How do I clone objects from ImageEnVect to another?
My code works for iekBITMAP but not vector graphics like iekLINE.
I tried:
ImageEnVect2.IEBitmap.Assign(ImageEnVect1.Layers[0].Bitmap);
ImageEnVect1.DrawObjectsToBitmap(ImageEnVect2.IEBitmap, False, False);
ImageEnVect2.update;
But when adding iekLINE I get an access violation in
procedure TIECanvas.DrawLine(X1, Y1, X2, Y2:integer);
What is the best approach to do this?
Thanks & regards
Eric
Here is test code:
procedure TForm1.FormCreate(Sender: TObject);
begin
ImageEnVect1.IO.LoadFromFilePNG('background.png');
end;
procedure TForm1.CloneView;
begin
//clone ImageEnVect1 background and objects to ImageEnVect2
ImageEnVect2.IEBitmap.Assign(ImageEnVect1.Layers[0].Bitmap);
ImageEnVect1.DrawObjectsToBitmap(ImageEnVect2.IEBitmap, False, False);
ImageEnVect2.update;
end;
procedure TForm1.ImageEnVect1Paint(Sender: TObject);
begin
CloneView;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
with ImageEnVect1 do
begin
//bitmap works
ObjKind[IEV_NEXT_INSERTED_OBJECT] := iekBITMAP;
ObjLeft[IEV_NEXT_INSERTED_OBJECT] := 10;
ObjTop[IEV_NEXT_INSERTED_OBJECT] := 200;
ObjWidth[IEV_NEXT_INSERTED_OBJECT] := 100;
ObjHeight[IEV_NEXT_INSERTED_OBJECT] := 100;
SetObjBitmapFromFile(IEV_NEXT_INSERTED_OBJECT, 'arrow.png');
ObjPenColor[IEV_NEXT_INSERTED_OBJECT] := clRed;
AddNewObject;
end;
with ImageEnVect1 do
begin
//vector fails
ObjKind[IEV_NEXT_INSERTED_OBJECT] := iekLINE;
ObjLeft[IEV_NEXT_INSERTED_OBJECT] := 10;
ObjTop[IEV_NEXT_INSERTED_OBJECT] := 10;
ObjWidth[IEV_NEXT_INSERTED_OBJECT] := 100;
ObjHeight[IEV_NEXT_INSERTED_OBJECT] := 100;
ObjPenWidth[IEV_NEXT_INSERTED_OBJECT] := 10;
ObjPenColor[IEV_NEXT_INSERTED_OBJECT] := clRed;
AddNewObject;
end;
end;