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
 Border and text overlay?

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
PeterPanino Posted - Jun 15 2017 : 08:25:09
In a TImageEnView 7.0, which is the most simple way to programmatically:

• Add a small text overlay with (semi-transparent) background in the center of the image. "Semi-transparent background means" that the underlying image should slightly shine trough the background area of the text while the text itself should be completely opaque.

Something like this:



5   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Jun 18 2017 : 22:22:54
Hi

Yes, unfortunately GdipMeasureString often overestimates the size of text. In that case it is given as 73 x 20. Hence the extra padding.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
w2m Posted - Jun 16 2017 : 10:55:01
TIETextLayer(ImageEnView.CurrentLayer).Alignment := iejCenter;
will center the text horizontally. I have found that when the Textlayer Alignment property is set to iejCenter then text is "approximately centered' but it is not centered accurately. It appears that the blank space on the right side of the text is always wider than the blank space to the left side of the text. I have also found that when an alignment of iejJustify is used the text alignment is not changed at all. In some cases you may want to use an alignment of iejRight.

While the alignment works, the alignment is not perfect... at least from my testing. Perhaps the horizontal and vertical text alignment code can be improved a little for iejCenter and iejJustify to be more accurate.

You can also change the font to see if that the alignment is improved. Some fonts may produce the problem while other fonts seem to work better than others.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
PeterPanino Posted - Jun 16 2017 : 08:12:56
I removed the line:
LayersMergeAll();

Now the image size is correct. But the text is not horizontally center-aligned inside the white area. It is always left-aligned inside the white area. Even if I have:

TIETextLayer(CurrentLayer).Alignment := iejCenter;

This is how it looks:



You can see how the text is left-aligned inside the area.

This is the code I used:

with DragDropForm.formDragDrop.imgCoverDrag do
  begin
    LayersAdd('ME DROP', 10, clRed, 'Arial Black', [fsBold]);
    //TIETextLayer(CurrentLayer).AutoSize := True;
    TIETextLayer(CurrentLayer).Alignment := iejCenter;
    TIETextLayer(CurrentLayer).Text := 'DROP ME';
    CurrentLayer.FillColor := clWhite;
    CurrentLayer.BorderColor := clNone;
    CurrentLayer.PosX := IELayer_Pos_HCenter;
    CurrentLayer.PosY := IELayer_Pos_VCenter;
    TIETextLayer(CurrentLayer).SizeToText();
  end;


And the text is not exactly vertically centered in the white area either.
PeterPanino Posted - Jun 16 2017 : 08:00:01
Hi Nigel, unfortunately, this code did not work for me. (Compiler complained: Wrong overload for LayersAdd). This code did compile:

with DragDropForm.formDragDrop.imgCoverDrag do
  begin
    LayersAdd( 'DROP ME', 32, clRed, 'Arial Black', [fsBold],  IELayer_Pos_HCenter, IELayer_Pos_VCenter);
    TIETextLayer( CurrentLayer ).SizeToText();
    CurrentLayer.PosX := IELayer_Pos_HCenter;
    CurrentLayer.PosY := IELayer_Pos_VCenter;

    CurrentLayer.FillColor  := clWhite;
    CurrentLayer.BorderColor := clNone;

    // Note: use Transparency if the image does not have an alpha channel
    CurrentLayer.Opacity := 0.7;

    LayersMergeAll();
  end;


However, it makes the image smaller! And the text is not positioned in the center of the image!
xequte Posted - Jun 15 2017 : 21:22:52
Hi

It would be easiest to use a text layer and then merge it into the image:

https://www.imageen.com/help/TIETextLayer.html


It would be something like:

with ImageEnView1 do
begin
  LayersAdd( 'Text', 'Arial Black', 42, clRed, [fsBold] );
  TIETextLayer( CurrentLayer ).SizeToText();
  CurrentLayer.PosX := IELayer_Pos_HCenter;
  CurrentLayer.PosY := IELayer_Pos_VCenter;

  CurrentLayer.FillColor  := clWhite;
  CurrentLayer.BorderColor := clNone;

  // Note: use Transparency if the image does not have an alpha channel
  CurrentLayer.Opacity := 0.7;

  LayersMergeAll();
end;


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