I create a Text Layer with this code:
procedure TForm1.ButtonClick(Sender: TObject);
begin
ImageEnView1.LayersAdd(
' Caption',
12,
clYellow,
'Arial'
);
TIETextLayer(ImageEnView1.CurrentLayer).PosX := 0;
TIETextLayer(ImageEnView1.CurrentLayer).PosY := ImageEnView1.IEBitmap.Height;
TIETextLayer(ImageEnView1.CurrentLayer).Layout := ielCenter;
TIETextLayer(ImageEnView1.CurrentLayer).Width := ImageEnView1.IEBitmap.Width;
TIETextLayer(ImageEnView1.CurrentLayer).Height := 50;
TIETextLayer(ImageEnView1.CurrentLayer).BorderWidth := 0;
TIETextLayer(ImageEnView1.CurrentLayer).FillColor := clYellow;
TIETextLayer(ImageEnView1.CurrentLayer).Locked := True;
ImageEnView1.LayersMerge(True);
TIETextLayer(ImageEnView1.CurrentLayer).Update;
StatusBar.SimpleText :=
'Width: ' + IntToStr(ImageEnView1.IEBitmap.Width) +
', Height: ' + IntToStr(ImageEnView1.IEBitmap.Height);
end;
This results in the following errors:
1. One pixel is missing on the right side:

2. One Pixel is missing on the bottom (Height should be 100):

Here is the source code (please put the file TestImage.bmp into the directory with the exe file):
attach/PeterPanino/202212941448_LayerInaccuracies.zip
2.43 KB
Questions:
1. Is it enough to add 1 pixel to the Layer width and 1 pixel to the Layer height to compensate for these errors?
TIETextLayer(ImageEnView1.CurrentLayer).Width := ImageEnView1.IEBitmap.Width + 1;
TIETextLayer(ImageEnView1.CurrentLayer).Height := 50 + 1;
2. Could these errors add up to higher values in some circumstances?