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
 Copy selection to another TImageEnVect

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
jwest Posted - Jul 02 2011 : 19:04:15
Hi,

I have a TImageEnVect with vectorial objects.
I select a rectangle with a parcel of the image and with some vectorial objects into it.

How could I copy the content of this rectangle(parcel of image and objects) to another TImageEnVect?

Thanks in Advance,

Luiz
4   L A T E S T    R E P L I E S    (Newest First)
jwest Posted - Jul 04 2011 : 06:43:37
With this code, all is working.
Thanks for your help.

  procedure SelObjsInRect(im:TImageEnVect;aobj: integer; xx1, yy1, xx2, yy2: integer);
  var
    o: integer;
    ax1, ay1, ax2, ay2: integer;
    rc:TRect;
    Kind:TIEVObjectKind;
  begin
    if aobj = -3 then
    begin
      for o := 0 to  im.ObjectsCount - 1 do
        SelObjsInRect(im, im.GetObjFromIndex(o) , xx1, yy1, xx2, yy2) 
    end
    else
    begin
        im.GetObjRect(aobj,rc);
        ax1 := rc.left;
        ay1 := rc.top;
        ax2 := rc.Right;
        ay2 := rc.Bottom;
        Kind:=im.ObjKind[aobj];
        if (Kind = iekLINE) or (Kind = iekRULER) or (Kind = iekPOLYLINE) or (Kind = iekANGLE) or (Kind = iekLINELABEL) then
          OrdCor(ax1, ay1, ax2, ay2);
        if (ax1 >= xx1) and (ax2 <= xx2) and (ay1 >= yy1) and (ay2 <= yy2) and (not im.IsSelObject(aobj)) then
          im.AddSelObject(aobj);
    end;
  end;

prcodeure copy_objects_and_image_from_rect;
begin
        Item:= TImageEnVect.create(self);
        ........
        if ( ImageEnVect1.Selected )then begin
          ImageEnVect1.CopySelectionToIEBitmap(Item.IEBitmap);
          SelObjsInRect(ImageEnVect1,-3,
           ImageEnVect1.SelX1, ImageEnVect1.SelY1,
           ImageEnVect1.SelX2, ImageEnVect1.SelY2);
          for i:=0 to ImageEnVect1.SelObjectsCount - 1 do begin
            hobj:=ImageEnVect1.SelObjects[i];
            ImageEnVect1.GetObjRect(hobj,rc);
            kk:=ImageEnVect1.ObjLeft[hobj];
            ImageEnVect1.CopyObjectTo(hobj ,Item);
            jj:=ImageEnVect1.SelX1;
            Item.ObjLeft[-2]:=kk-jj;
            kk:=ImageEnVect1.ObjTop[hobj];
            jj:=ImageEnVect1.SelY1;
            Item.ObjTop[-2]:=kk-jj;
          end;
          Item.Update;
          ImageEnVect1.UnSelAllObjects;
end
w2m Posted - Jul 03 2011 : 16:57:56
The objects are copied here.

When you make the selection with the mouse do the objects have selection handles? After you select and there are no objects with handles then the ImageEnVect1.CopySelectedObjectsTo( ImageEnVect2 ) will not work.

How are you selecting the objects? With Mouseinteract = miselect?

I used the vectorial demo to test this. Try it with that first before your app. You should not have to do anything more to get the objecys to appear.

William Miller
jwest Posted - Jul 03 2011 : 15:14:54
Hi,

I tried your code but only the image is copied. No vectorial objects appears.

I think I have to loop into objects and convert coordinates, width, height to the new destiny.

Some help will be appreciated.


Regards,

Luiz

w2m Posted - Jul 03 2011 : 07:03:27
Selecting the objects with miSelect works fairly well but is not perfect. You may be able to improve selecting the objects with the selection... Maybe Fabrizio will assist here.

But for now try this:

procedure TMainForm.ImageEnVect1MouseMove( Sender: TObject; Shift: TShiftState; X, Y: Integer );
var
  hobj: Integer;
  Distance: Double;
begin
  if ImageEnVect1.MouseCapture then
  begin
    ASelectionChanging := true;
    // Select object if the object is in the selection
    // This is not perfect but works
    ImageEnVect1.MaxSelectionDistance := ImageEnVect1.SelX2 - ImageEnVect1.SelX1;
    if ImageEnVect1.MaxSelectionDistance < 0 then
      ImageEnVect1.MaxSelectionDistance := ImageEnVect1.SelY2 - ImageEnVect1.SelY1;
    if ImageEnVect1.MouseInteract = [ miSelect ] then
    begin
      hobj := ImageEnVect1.FindObjectAt( X, Y, Distance );
      if ( hobj <> -1 ) and ( Distance < ImageEnVect1.MaxSelectionDistance ) then
      begin
        if not ImageEnVect1.IsSelObject( hobj ) then
          ImageEnVect1.AddSelObject( hobj );
      end;
    end;
  end;
end;

procedure TMainForm.CopySelectedObjects1Click( Sender: TObject );
// copy the selection and selected objects to ImageEnVect2
var
  rc: TRect;
begin
  // copy background selection to ImageEnVect2.IEBitmap
  ImageEnVect1.CopySelectionToIEBitmap( ImageEnVect2.IEBitmap, false );
  // copy selected objects to ImageEnVect2
  ImageEnVect1.CopySelectedObjectsTo( ImageEnVect2 );
  // UnSelAllObjects
  ImageEnVect1.UnSelAllObjects;
  // show the number og objects in ImageEnVect2
  showmessage( IntToStr( ImageEnVect2.ObjectsCount ) );
end;


William Miller