Author |
Topic |
|
yogiyang
India
725 Posts |
Posted - Aug 25 2017 : 09:42:10
|
Hello,
I am using following code to Add Text to a Layer, Rotate it and place it towards the right edge in the Center of the main image:
procedure TfrmScanAndPrint.DoStampImage(ieTemp: TImageEnView);
var
i: integer;
j: integer;
iLayer: integer;
iSpacing: integer;
iText: string;
iRows: integer;
begin
Screen.Cursor := crHourGlass;
try
ieTemp.DeSelect;
ieTemp.LayersCreateFromText('Duplicate Copy...','Tahoma',14,clRed,[fsBold],false,1,0,0,True);
ieTemp.LayersRotateAll(90, True, True);
ieTemp.CurrentLayer.PosX := ieTemp.Layers[0].Width - ieTemp.CurrentLayer.Width - 5;
ieTemp.CurrentLayer.PosY := ieTemp.Layers[0].PosX + ieTemp.CurrentLayer.Height + 5;
ieTemp.LayersAlign(ilaAlignHorizontalCenters);
ieTemp.LayersAlign(ilaAlignVerticalCenters);
ieTemp.Update;
ieTemp.LayersMergeAll;
finally
Screen.Cursor := crDefault;
end;
end;
But this is not the right way I can tell. Actually I was trying to align the layers to get exact/perfect adjustment for the text.
I am attaching an image as per which I want final output, but here the text should always be in center and rotated and in vertical center irrespective of image height.
TIA
Yogi Yang |
|
w2m
USA
1990 Posts |
Posted - Aug 25 2017 : 10:21:08
|
Is this what you are looking for?
If so, here is the code:
procedure TForm1.Button1Click(Sender: TObject);
begin
Screen.Cursor := crHourGlass;
try
ImageEnView1.DeSelect;
ImageEnView1.LayersCreateFromText('Duplicate Copy...', 'Tahoma', 36, clRed,
[fsBold], false, 1, 0, 0, True);
ImageEnView1.LayersRotateAll(90, True, True);
ImageEnView1.CurrentLayer.PosX := ImageEnView1.Layers[0].Width div 2 -
ImageEnView1.CurrentLayer.Width;
ImageEnView1.CurrentLayer.PosY := ImageEnView1.Layers[0].Height div 2 -
ImageEnView1.IEBitmap.IECanvas.TextWidth('Duplicate Copy...');
ImageEnView1.LayersAlign(ilaAlignHorizontalCenters);
ImageEnView1.LayersAlign(ilaAlignVerticalCenters);
ImageEnView1.Update;
ImageEnView1.LayersMergeAll;
finally
Screen.Cursor := crDefault;
end;
end; Bill Miller Adirondack Software & Graphics Email: w2m@hughes.net EBook: http://www.imageen.com/ebook/ Custom Commercial ImageEn Development |
|
|
yogiyang
India
725 Posts |
Posted - Aug 25 2017 : 11:04:03
|
Thanks Bill,
But no.
I have attached an image in my original post. I want the text to come at the location shown in the attached image.
In your sample the text is in center in both way. It should be vertically in center and on the right edge without getting truncated.
TIA
Yogi Yang |
|
|
w2m
USA
1990 Posts |
Posted - Aug 25 2017 : 11:23:14
|
How is this?
procedure TForm1.AddText1Click(Sender: TObject);
begin
Screen.Cursor := crHourGlass;
try
ImageEnView1.DeSelect;
ImageEnView1.LayersCreateFromText('Duplicate Copy...', 'Tahoma', 42, clRed,
[fsBold], false, 1, 0, 0, True);
ImageEnView1.LayersRotateAll(90, True, True);
ImageEnView1.CurrentLayer.PosX := ImageEnView1.Layers[0].Width -
ImageEnView1.IEBitmap.IECanvas.TextWidth('Duplicate Copy...');
ImageEnView1.CurrentLayer.PosY := ImageEnView1.Layers[0].Height div 2 -
ImageEnView1.IEBitmap.IECanvas.TextWidth('Duplicate Copy...') * 2;
ImageEnView1.LayersAlign(ilaAlignHorizontalCenters);
ImageEnView1.LayersAlign(ilaAlignVerticalCenters);
ImageEnView1.Update;
ImageEnView1.LayersMergeAll;
finally
Screen.Cursor := crDefault;
end;
end;
Bill Miller Adirondack Software & Graphics Email: w2m@hughes.net EBook: http://www.imageen.com/ebook/ Custom Commercial ImageEn Development
|
|
|
yogiyang
India
725 Posts |
Posted - Sep 04 2017 : 00:54:55
|
Bill,
Thanks for the code sample. As usual your code works like a charm.
Sorry for my late reply as I was busy with another project.
TIA
Yogi Yang |
|
|
|
Topic |
|
|
|