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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Clone ImageEnVect objects
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

egrobler

42 Posts

Posted - Apr 29 2014 :  00:25:30  Show Profile  Reply
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;

w2m

USA
1990 Posts

Posted - Apr 29 2014 :  04:31:02  Show Profile  Reply
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
Go to Top of Page

egrobler

42 Posts

Posted - Apr 29 2014 :  09:22:41  Show Profile  Reply
Thank you William

It works :-)

Your feedback is always excellent.

Regards
Eric
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: