ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder
ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Using SoftShadow in Text Layer - TIETextLayer
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

nachbar

USA
14 Posts

Posted - Aug 28 2019 :  14:51:32  Show Profile  Reply
I have a utility app I use to add text with a shadow to an adjusted bitmap. I had implemented that utility using TImageEnView.LayersCreateFromText, which had an AddShadow parameter, and it worked great. I was updating the utility, and LayersCreateFromText is now deprecated and no longer documented, with the recommendation to use TIETextLayer, which has a SoftShadow component.

However, I am not able to get the shadow to show up, even though Enabled is true and regardless of what I set for the radius, etc. The only shadow demo uses Proc->AddSoftShadow, but that just puts a shadow on the entire image, not shadowing the text. There is a nice picture in the help file of what shadowed text should look like, but no code to produce it.

I am using a throwaway (i.e., not displayed) TImageEnView, assigning the image from the TIEBitmap to Layers[0]->Bitmap, creating a TIETextLayer using LayersAdd, setting the text and other info on the TIETextLayer, calling SizeToText on the layer, and then calling Update() on the TImageEnView. Then I use IELayersMerge to merge both of the layers together into a bitmap.

All of that works fine to put text on the bitmap, but I cannot cause a shadow to appear. If I call AddShoftShadow on the TImageEnView's Proc, I get the error "Active layer does not contain bitmap." -- That is true - the active layer is a TIETextLayer.

Can you tell me how to put shadowed text on a bitmap, or provide some working code using TIETextLayer->SoftShadow?

Thank you.

James Nachbar

xequte

4714 Posts

Posted - Aug 29 2019 :  17:15:17  Show Profile  Reply
Hi James

You can continue to use LayersCreateFromText. It won't be removed.

This works in my testing:

// Load an image, add text with a soft shadow and save it
var
  iev : TImageEnView;
begin
  iev := TImageEnView.Create( nil );
  iev.IEBitmap.LoadFromFile( 'd:\image.jpg' );
  iev.LayersAdd( ielkText, 100, 100 );
  TIETextLayer( iev.CurrentLayer ).Text := 'This is a test';
  TIETextLayer( iev.CurrentLayer ).Font.Size := 30;
  TIETextLayer( iev.CurrentLayer ).Font.Style := [fsBold];
  iev.CurrentLayer.SoftShadow.Enabled := True;
  iev.LayersMergeAll();
  iev.IEBitmap.SaveToFile( 'd:\image_out.jpg' );
  iev.Free;
end;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

nachbar

USA
14 Posts

Posted - Aug 29 2019 :  19:57:32  Show Profile  Reply
Thank you. Yes, LayersCreateFromText works fine. Will LayersCreateFromText be restored to the documentation?

James Nachbar
Go to Top of Page

xequte

4714 Posts

Posted - Aug 29 2019 :  23:14:05  Show Profile  Reply
Hi James

No, unfortunately LayersCreateFromText creates an image layer with text drawn onto it, so it's not a great way to create a "text layer".

If the layer is sized after creation then it will look awful.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To: