Hi Yogi,
I added the following to the Photo2 demo:
procedure TMainForm.SpeedButton14Click(Sender: TObject);
{ Create text in a transparent layer with textout }
var
iChild: TMDIChild;
iLayer: integer;
iLayerWidth: integer;
iLayerHeight: integer;
begin
{ Get the ActiveMDIChild }
iChild := ActiveMDIChild as TMDIChild;
{ Add fully transparent text layer }
iLayer := iChild.ImageEnView1.LayersAdd;
{ Fill the new layer with white }
iChild.ImageEnView1.Proc.Fill(CreateRGB(255, 255, 255));
{ Set the text font }
iChild.ImageEnView1.Bitmap.Canvas.Font.Name := 'Times New Roman';
iChild.ImageEnView1.Bitmap.Canvas.Font.Color := clYellow;
iChild.ImageEnView1.Bitmap.Canvas.Font.Size := 150;
{Draw the text }
iChild.ImageEnView1.Bitmap.Canvas.TextOut(0, 0, 'ImageEn Text');
{Get the text extent }
iLayerHeight := iChild.ImageEnView1.Bitmap.Canvas.TextHeight('ImageEn Text');
iLayerWidth := iChild.ImageEnView1.Bitmap.Canvas.TextWidth('ImageEn Text');
{ Remove the white, making layer transparent }
iChild.ImageEnView1.Proc.SetTransparentColors(CreateRGB(255, 255, 255), CreateRGB(255, 255, 255),
0);
{ Make sure layer and is visible }
iChild.ImageEnView1.CurrentLayer.VisibleBox := True;
iChild.ImageEnView1.CurrentLayer.Selectable := True;
iChild.ImageEnView1.LayersDrawBox := True;
{ Set the layer dimensions to text extent }
iChild.ImageEnView1.CurrentLayer.Width := iLayerWidth;
iChild.ImageEnView1.CurrentLayer.Height := iLayerHeight;
{ Allow selection of transparent layers
If you do not add this then you can only move the layer by clicking on a pixel that isnot transparent }
iChild.ImageEnView1.SelectionOptions := iChild.ImageEnView1.SelectionOptions +
[iesoSelectTranspLayers];
{Set MouseInteract to allow select, move and resize layers }
Layers1.Checked := True;
iChild.ImageEnView1.MouseInteract := [miMoveLayers, miResizeLayers];
iChild.ImageEnView1.Update;
end;
procedure TMainForm.SpeedButton15Click(Sender: TObject);
{ Create antialiased text in a transparent layer with iegidplus }
var
iChild: TMDIChild;
iLayer: integer;
iLayerWidth: integer;
iLayerHeight: integer;
iIECanvas1: TIECanvas;
begin
{ Get the ActiveMDIChild }
iChild := ActiveMDIChild as TMDIChild;
{ Add fully transparent text layer }
iLayer := iChild.ImageEnView1.LayersAdd;
{ Fill the new layer with white }
iChild.ImageEnView1.Proc.Fill(CreateRGB(255, 255, 255));
{ Draw on the Non-Alpha Canvas }
iIECanvas1 := TIECanvas.Create(iChild.ImageEnView1.IEBitmap.Canvas, True,
True);
try
iIECanvas1.Font.Name := 'Times New Roman';
iIECanvas1.Font.Color := clYellow;
iIECanvas1.Font.Size := 150;
iIECanvas1.TextOut(0, 0, 'ImageEn Text');
{ Remove the white, making the layer transparent }
iChild.ImageEnView1.Proc.SetTransparentColors(CreateRGB(255, 255, 255), CreateRGB(255, 255,
255),
0);
iChild.ImageEnView1.CurrentLayer.PosX := 0;
iChild.ImageEnView1.CurrentLayer.PosY := 0;
{ Get the screen dimensions of the text to set layer dimensions }
iChild.ImageEnView1.CurrentLayer.Width := iIECanvas1.TextWidth('ImageEn Text');
iChild.ImageEnView1.CurrentLayer.Height := iIECanvas1.TextHeight('ImageEn Text');
{ Allow selection of transparent layers
If you do not add this then you can only move the layer by clicking on a pixel that isnot transparent }
iChild.ImageEnView1.SelectionOptions := iChild.ImageEnView1.SelectionOptions +
[iesoSelectTranspLayers];
iChild.ImageEnView1.CurrentLayer.VisibleBox := True;
iChild.ImageEnView1.CurrentLayer.Selectable := True;
iChild.ImageEnView1.LayersDrawBox := True;
finally
iIECanvas1.Free();
end;
iChild.ImageEnView1.Cursor := crArrow;
{ Set the mouseinteract so the layer can be selected, resized and moved }
iChild.ImageEnView1.MouseInteract := [miMoveLayers, miResizeLayers];
iChild.ImageEnView1.Update;
Layers1.Checked := True;
end;
You should remember that the text is not an "object" like ImageEnVect... rather the text is drawn or painted on the bitmap. So when you resize the layer the text resizes along with the bitmap. If you want a small layer the text will also be small.
So I think there is no way to create a small layer with large text with TextOut. If you need resizeable text it would probablly be better to create an ImageEnVect text object to allow more control over the text .
William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html