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
 ImageEnMView and draw custom text on each image in it
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

papa.john

10 Posts

Posted - Oct 07 2024 :  10:19:52  Show Profile  Reply
Hi. Is it possible to draw a semi-transparent rectangle with text on each image in ImageEnMView? I need something like this:


xequte

38981 Posts

Posted - Oct 07 2024 :  18:10:49  Show Profile  Reply
Hi

Do you mean draw it upon the display, without affecting the actual image?

Here is an example:

// Output the image size in the bottom left of the thumbnail (with a semi transparent background)
procedure TMainForm.ImageEnMView1ImageDraw2(Sender: TObject; idx, Left, Top: Integer; ImageRect: TRect; Canvas: TCanvas);
const
  Right_Margin  = 2;
  Bottom_Margin = 2;
  Text_Margin   = 2;
var
  x1, y1, x2, y2: integer;
  iec: TIECanvas;
  ss: string;
  sz: TSize;
begin
  ss := format( '%d x %d', [ ImageEnMView1.ImageWidth[idx],  ImageEnMView1.ImageHeight[idx] ]);

  // Create our TIECanvas from the regular TCanvas
  iec := TIECanvas.Create( Canvas );
  try
    iec.Font.Size  := 8;
    iec.Font.Color := clWhite;
    iec.Font.Style := [fsBold];

    sz := iec.TextExtent( ss );

    x1 := ImageRect.Right - sz.cx - Right_Margin;
    y1 := ImageRect.Bottom - sz.cy - Bottom_Margin;
    x2 := ImageRect.Right - Right_Margin;
    y2 := ImageRect.Bottom - Bottom_Margin;

    iec.Brush.Color := clBlack;
    iec.Brush.Style := bsSolid;
    iec.Brush.Transparency := 196;
    iec.Pen.Style := psClear;
    iec.Rectangle( x1 - Text_Margin, y1, x2 + Text_Margin, y2 );
    iec.TextOut( x1, y1, ss );
  finally
    iec.Free();
  end;
end;


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

papa.john

10 Posts

Posted - Oct 08 2024 :  01:33:15  Show Profile  Reply
This is exactly what I need, thank you very much!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: