ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Clone ImageEnVect objects

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
egrobler Posted - Apr 29 2014 : 00:25:30
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;

2   L A T E S T    R E P L I E S    (Newest First)
egrobler Posted - Apr 29 2014 : 09:22:41
Thank you William

It works :-)

Your feedback is always excellent.

Regards
Eric
w2m Posted - Apr 29 2014 : 04:31:02
DrawObjectsToBitmap just draws a bitmap of the object it does not clone it. You should use CopyObjectTo to actually clone.. meaning create a duplicate object.

TImageEnVect.CopyObjectTo

Declaration


function CopyObjectTo(hobj: integer; Dest: TImageEnVect):integer;

Description

Call CopyObjectTo to write only the hobj object to the Dest TImageEnVect component. Returns the handle of the created object.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Custom ImageEn Development