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
 TextOut not ablet to create text properly

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
yogiyang Posted - May 24 2013 : 22:22:22
I am using following code to add Text (when no layer is active) to ImageEN control:
procedure TMainForm.cmdInsertTextObjectClick(Sender: TObject);
var
  Child: TMDIChild;
begin
  Child := ActiveMDIChild as TMDIChild;
  if Child = nil then
    exit;
  with Child.ImageEnView1 do
  begin
    LockUpdate;
    LayersAdd;
    Proc.CastColor(1, 1, CreateRGB(255, 255, 255), 0);
    
    IEBitmap.Canvas.Font.Name := 'Tahoma';
    IEBitmap.Canvas.Font.Size := 300;

    IEBitmap.Canvas.TextOut(0, 0, txtAddText.Text);
    Proc.SetTransparentColors(CreateRGB(125, 125, 125), CreateRGB(255,255, 255),0); 
// remove the white, making it as transparent

    UnLockUpdate;
  end;
end;


The output that I get in ImageEn is:



How ever I may try to get it to show whole text I am not able to using its sizing handles.

The most interesting part (which is probably related to LayerAdd) is that if I have a selected layer, then the text object added becomes of selected layer's size even if the size of text is just 72 points.

To set Text Layer's size to the size of text I am using following code:
Child.ImageEnView1.DeSelect;

Is this right?

How to solve this problem?

TIA

Yogi Yang




Yogi Yang
2   L A T E S T    R E P L I E S    (Newest First)
yogiyang Posted - May 28 2013 : 22:16:56
Thanks William.

From the two code sample which one is better?

Regards,


Yogi Yang
w2m Posted - May 25 2013 : 07:32:04
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