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
 LayersCreateFromText Bugs

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
zerob Posted - Mar 05 2015 : 04:04:44
Dear xequte

It seems that LayersCreateFromText has some bugs.

If you enable smoothing and shadow, the text doesn't look that good anymore (white edges appear) (caused by simple settranspartentcolor instead of proper alphachannels).


ImageEnView1.LayersCreateFromText('Project1.exe', //this is just a random text
                                  'Tahoma', 72, clRed, [fsBold],
                                  True,3,2,0,True);



I also found another strange bug.

Every time i create a layer by LayersCreateFromText, the new layer gets smaller, the next one even smaller and so on... till one if the new layers is so small that it isn't shown anymore.

The first one is:
601x94
The second one is:
594x72
The third one is:
587x50
The fourth one is:
580x28
So it seems they shrink 7 pixels in width and 22 pixels in height everytime a new one is created


ImageEnView1.MouseInteract := [miMoveLayers, miResizeLayers];
ImageEnView1.LayersCreateFromText('Project1.exe',
                                  'Tahoma', 72, clRed, [fsBold],
                                  False,3,2,0,False);
ImageEnView1.LayersCreateFromText('Project1.exe',
                                  'Tahoma', 72, clRed, [fsBold],
                                  False,3,2,0,False);
ImageEnView1.LayersCreateFromText('Project1.exe',
                                  'Tahoma', 72, clRed, [fsBold],
                                  False,3,2,0,False);
ImageEnView1.LayersCreateFromText('Project1.exe',
                                  'Tahoma', 72, clRed, [fsBold],
                                  False,3,2,0,False);


Also it would be nice if things from TImageEnProc could be used to any layer or iebitmap instead of using the last added layer.

Regards
Zerob

6   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Mar 08 2015 : 18:21:37
A block of code is worth a thousand words:

// create a layer on a TImageEnView with shadow text
var
  CompositingCanvas: TIECanvas;
begin
  ImageEnView1.LayersAdd;

  // Area that is larger than what we need
  ImageEnView1.IEBitmap.Allocate(500, 500);
  ImageEnView1.AlphaChannel.Fill(0);

  // Rect(0,0,500,100) is just the estimated required area
  CompositingCanvas := ImageEnView1.IEBitmap.CreateROICanvas(Rect(0, 0, 500, 100), true, true, true);

  CompositingCanvas.Brush.Color := clRed;
  CompositingCanvas.Font.Name := 'Tahoma';
  CompositingCanvas.Font.Height := 72;
  CompositingCanvas.DrawText('Hello World!', Rect(0, 0, 500, 300));  // use DrawText instead of TextOut

  // This will also copy the content back to the IEBitmap
  CompositingCanvas.Free();

  // Add a Soft Shadow
  ImageEnView1.Proc.AddSoftShadow(5, 5, 1);

  // Remove excess transparent area
  ImageEnView1.Proc.CropTransparentBorder;

  ImageEnView1.Update();
end;


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
zerob Posted - Mar 07 2015 : 05:10:39
Can you explain this alpha compositing a bit? :-)
xequte Posted - Mar 06 2015 : 23:31:57
Hi

Yes, good work. That is the best way to handle it. Anyway for the next release we have added alpha compositing to TIECanvas, which will make working with transparency and a canvas much easier.

We have also fixed LayersCreateFromText and Proc.TextOut.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
zerob Posted - Mar 06 2015 : 00:51:12
Hi, i did create a bugfixed function which does a black/white of the text and copies it into the alpha channel and then fills the foreground with the textcolor:

This uses an alphachannel instead of the settransparentcolor (white) that the original function uses.


function ImageEnViewEx.LayersCreateFromText(const sText : string;
                                           const sFontName : string;
                                           iFontSize : Integer;
                                           cFontColor : TColor;
                                           Style : TFontStyles;
                                           bAddShadow: boolean = False;
                                           iBlurRadius : Integer = 3;
                                           iShadowOffset : Integer = 2;
                                           Angle : Integer = 0;
                                           bAntiAlias : Boolean = true) : integer;
begin
  // add a new layer
  Result := LayersAdd;
  // Fill the new layer with black for empty alpha
  Proc.Fill(clBlack);
  // Output our text in white for visible alpha
  Proc.TextOut(0, 0, sText, sFontName, iFontSize, clWhite, Style, Angle, bAntiAlias);
  // Copy the black / white to alpha channel
  LayersCopyToAlpha(Result);
  // Fill the color with the font color
  Proc.Fill(cFontColor);
  // Add our shadow
  if bAddShadow then
    Proc.AddSoftShadow(iBlurRadius, iShadowOffset, iShadowOffset);

  // Remove the excess transparency
  Proc.CropTransparentBorder;
end;
xequte Posted - Mar 05 2015 : 22:18:12
Also, you can set LayersCurrent to specify which layer TImageEnProc will affect:

http://www.imageen.com/help/TImageEnView.LayersCurrent.html

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
xequte Posted - Mar 05 2015 : 20:58:06
Hi

The sizing issue is fixed in the next update (ready next week).

We will investigate the issue of TextOut leaving jaggies. What helper function did you use in your second example?



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