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
 How to Draw Rectangle that stays proper

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
yogiyang Posted - Jun 17 2016 : 01:49:25
Hello,

I am finding it hard to describe the problem properly but let me try....

I am trying to draw a border in ImageEnView. With help from Bill I managed to draw a border by placing code in DrawBackBuffer event.

But the problem is that the border drawn changes size when the view changes. Meaning if the zoom of ImageEnView is changed the border does not stay as it is. Instead it is always drawn in the visible part of ImageEnView.

How to draw a border around ImageEnView leaving 25 pixels as margin which will stay the same even when user zooms in or out?

For better understanding here are a few screen shots.





Here is the code that I am using:
procedure TForm1.ImageEnVect1DrawBackBuffer(Sender: TObject);
{ Automatically draw the grid in the background, eliminates the need to use objects and is much faster and much better
  than using objects }
var
  ix1: Integer;
  iy1: Integer;
  ix2: Integer;
  iy2: Integer;
begin
  { Get the corners of the bitmap }
  ix1 := ImageEnVect1.OffsetX;
  iy1 := ImageEnVect1.OffsetY;
  ix2 := ImageEnVect1.ExtentX;
  iy2 := ImageEnVect1.ExtentY;
  { Draw a blue rectangle around the bitmap }
  ImageEnVect1.BackBuffer.Canvas.Pen.Width := 1;
  ImageEnVect1.BackBuffer.Canvas.Pen.Color := clGreen;
  ImageEnVect1.BackBuffer.Canvas.Pen.Style := psSolid;
  ImageEnVect1.BackBuffer.Canvas.Brush.Style := bsClear;
  ImageEnVect1.BackBuffer.Canvas.Rectangle(ix1 + 25, iy1 + 25, ix1 + ix2 - 25, iy1 + iy2 - 25);
  { Draw crosshairs }
  ImageEnVect1.BackBuffer.Canvas.Pen.Color := clBlack;
  ImageEnVect1.BackBuffer.Canvas.MoveTo(ix1 + ix2 div 2, iy1);
  ImageEnVect1.BackBuffer.Canvas.LineTo(ix1 + ix2 div 2, iy1 + iy2);
  ImageEnVect1.BackBuffer.Canvas.MoveTo(ix1, iy1 + iy2 div 2);
  ImageEnVect1.BackBuffer.Canvas.LineTo(ix1 + ix2, iy1 + iy2 div 2);
  {Draw 4 Simple Lines}
  ImageEnVect1.BackBuffer.Canvas.Pen.Color := clBlue;
  ImageEnVect1.BackBuffer.Canvas.MoveTo(ix1 + ix2 div 4 + 12, iy1);
  ImageEnVect1.BackBuffer.Canvas.LineTo(ix1 + ix2 div 4 + 12, iy1 + iy2);
  ImageEnVect1.BackBuffer.Canvas.MoveTo(ix1 + (ix2 div 4) * 3 - 12, iy1);
  ImageEnVect1.BackBuffer.Canvas.LineTo(ix1 + (ix2 div 4) * 3 - 12, iy1 + iy2);

  ImageEnVect1.BackBuffer.Canvas.MoveTo(ix1, iy1 + iy2 div 4 + 12);
  ImageEnVect1.BackBuffer.Canvas.LineTo(ix1 + ix2, iy1 + iy2 div 4 + 12);
  ImageEnVect1.BackBuffer.Canvas.MoveTo(ix1, iy1 + (iy2 div 4) * 3 - 12);
  ImageEnVect1.BackBuffer.Canvas.LineTo(ix1 + ix2, iy1 + (iy2 div 4) * 3 - 12);

end;

TIA


Yogi Yang
3   L A T E S T    R E P L I E S    (Newest First)
yogiyang Posted - Jul 13 2016 : 10:50:21
Hello,

One more thing that I observed is that the rectangle gets drawn even when we select a layer and at that time the size of the layer seems to apply.

TIA


Yogi Yang
yogiyang Posted - Jul 13 2016 : 08:03:34
Hello Nigel,

I have put this code in DrawBackBuffer Event

procedure TfrmMain.ievMainDrawBackBuffer(Sender: TObject);
var
  ix1: Integer;
  iy1: Integer;
  ix2: Integer;
  iy2: Integer;
begin
  if ievMain.IsEmpty2 then
    Exit;

  { Get the corners of the bitmap }
  ix1 := ievMain.XBmp2Scr(ievMain.OffsetX);
  iy1 := ievMain.YBmp2Scr(ievMain.OffsetY);
  ix2 := ievMain.XBmp2Scr(ievMain.IEBitmap.Width);
  iy2 := ievMain.YBmp2Scr(ievMain.IEBitmap.Height);

  //--------
  { Draw a blue rectangle around the bitmap }
  ievMain.BackBuffer.Canvas.Pen.Width := 1;
  ievMain.BackBuffer.Canvas.Pen.Color := clRed;
  ievMain.BackBuffer.Canvas.Pen.Style := psSolid;
  ievMain.BackBuffer.Canvas.Brush.Style := bsClear;
  ievMain.BackBuffer.Canvas.Rectangle(ix1 + ievMain.XBmp2Scr(10), iy1 +
    ievMain.YBmp2Scr(10), ix1 + ix2 - ievMain.XBmp2Scr(10),
       iy1 + iy2 - ievMain.YBmp2Scr(10));
  { Draw crosshairs }
  ievMain.BackBuffer.Canvas.Pen.Color := clBlack;
  ievMain.BackBuffer.Canvas.MoveTo(ix1 + ix2 div 2, iy1);
  ievMain.BackBuffer.Canvas.LineTo(ix1 + ix2 div 2, iy1 + iy2);

end;

But it is now drawing the required rectangle properly. Can you help correct my mistakes.

What I want is:


Again this should stay proper irrespective of Zoom.

TIA


Yogi Yang

xequte Posted - Jun 21 2016 : 21:52:14
Hi Yogi

To convert values between what is visible on-screen (given zoom and scrolling) and the underlying bitmap, see the methods such as:

http://www.imageen.com/help/TImageEnView.XBmp2Scr.html
http://www.imageen.com/help/TImageEnView.XScr2Bmp.html

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com