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
 PNG with transparent background + 40% opacity

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
aleatprog Posted - May 18 2024 : 04:25:01
Hi,

in order to watermark a PDF by adding an image to the highest z-index, I got an acceptable result by using a PNG with transparent background + 40% opacity (see image below).

The following code creates an image with transparent background, but I miss the point how to apply 40% opacity to the watermark text in order to get the underlaying text readable.

ievPng := TImageEnView.Create(nil);
  try
    with ievPng do
      begin
        IEBitmap.CreateAsAlphaChannel(992, 1403, ieMemory);
        LayersAdd('copyrighted extract - ' + FormatDateTime('c', Now), 28, clWebGainsboro, 'Arial');
        TIETextLayer(CurrentLayer).Rotate := 60;
        TIETextLayer(CurrentLayer).SizeToText();
        CurrentLayer.PosX := IELayer_Pos_HCenter;
        CurrentLayer.PosY := IELayer_Pos_VCenter;
        LayersMergeAll(True);
        Proc.SetTransparentColors(CreateRGB(255, 255, 255), CreateRGB(255, 255, 255), 0);
        Update;
        ImageEnView1.PdfViewer.Objects.AddImage(0, 0, Round(ImageEnView1.PdfViewer.PageWidth * 0.6), Round(ImageEnView1.PdfViewer.PageHeight * 0.6), ievPng.IEBitmap);
      end;
  finally
    ievPng.Free;
  end;
ImageEnView1.PdfViewer.ApplyChanges;
ImageEnView1.PdfViewer.SaveToFile(path);


Ale

2   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - May 20 2024 : 00:13:27
Nice one, Ale

Nigel
Xequte Software
www.imageen.com
aleatprog Posted - May 18 2024 : 04:41:14
Solved.

Simply apply transparency to the text color. For watermarks, as in my case, transparency could be applied to all colors of the bitmap. The result is perfect.

//set background transparent
Proc.SetTransparentColors(CreateRGB(255, 255, 255), CreateRGB(255, 255, 255), 0);
//apply 40% opacity to the bitmap
Proc.SetTransparentColors(CreateRGB(0, 0, 0), CreateRGB(254, 254, 254), 40);

Ale