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
 copy iebitmap rect to another iebitmap
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

kowal

Poland
42 Posts

Posted - Jul 25 2025 :  14:50:26  Show Profile  Reply
hello,
I'm trying to copy imageEnView VisibleBitmapRect to another ieBitmap
the problem is that nothing is copied to the dest.
what is my fault?

here is the snippet of my code

ipor is the name of my imageEnView

 function copy_iebitmap_rect_2_iebitmap: boolean;
  var   iebmp: tieBitmap;
        rect: TRect;
  begin
      iebmp := tiebitmap.Create;
      rect.left   := ipor.VisibleBitmapRect.Left;
      rect.top    := ipor.VisibleBitmapRect.Top;
      rect.Right  := ipor.VisibleBitmapRect.Right;
      rect.Bottom := ipor.VisibleBitmapRect.Bottom;
      rect.width  := ipor.VisibleBitmapRect.Width;
      rect.height := ipor.VisibleBitmapRect.Height;

      // from IE Help:
	  // CopyRectTo(Dest: TIEBitmap; SrcX, SrcY, DstX, DstY: integer; RectWidth, RectHeight: integer; CopyAlpha: boolean = false);

      iebmp.PixelFormat := ipor.ieBitmap.PixelFormat;  // added to help but with no effect
      ipor.ieBitmap.CopyRectTo(iebmp,           // dest
                        rect.Left, rect.Top,    // src =  605, 504
                        0, 0,                   // dest
                        rect.Width, rect.Height  //  = 801, 429
                        );
      result := (iebmp.Width>0);   //  iebmp.Width = 0
  end;

--
regards, Kowal

xequte

39097 Posts

Posted - Jul 27 2025 :  20:25:32  Show Profile  Reply
Hi Kowal

There are two issues here. Firstly, you don't set the size of the destination bitmap, so it will remain 0x0. Secondly, there is an issue with VisibleBitmapRect Left and Top positions.

The following code will work:

      iebmp := TIEBitmap.Create;
      rect.Left   := Round( ipor.ViewX / ipor.ZoomX * 100 );
      rect.Top    := Round( ipor.ViewY / ipor.ZoomY * 100 );
      rect.width  := ipor.VisibleBitmapRect.Width;
      rect.height := ipor.VisibleBitmapRect.Height;

      iebmp.Allocate( rect.width, rect.Height );

      iebmp.PixelFormat := ipor.ieBitmap.PixelFormat;  // added to help but with no effect
      ipor.ieBitmap.CopyRectTo(iebmp,           // dest
                        rect.Left, rect.Top,    // src =  605, 504
                        0, 0,                   // dest
                        rect.Width, rect.Height  //  = 801, 429
                        );
      result := (iebmp.Width>0);


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

kowal

Poland
42 Posts

Posted - Jul 28 2025 :  02:45:21  Show Profile  Reply
Hi Nigel,
It works ok, thank you for your help!

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