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
 Transparent drawing to TCanvas

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
HeartWare Posted - Feb 22 2018 : 09:22:18
How do you draw a TIEBitmap with AlphaChannel to a TCanvas?

IEBitmap.DrawToCanvas(Canvas,X,Y) doesn't seep to obey the transparency in the IEBitmap.

The IEBitmap was loaded from a disk file (.PNG with transparency) and if I save it back to another .PNG file, I can see that the transparency was preserved in the IEBitmap (also, AlphaChannel returns TRUE).

But if I use DrawToCanvas it doesn't appear to work.

I have attached the .PNG file, in case it is needed...



Also, a screen dump of the image drawn on a TGraphic's TCanvas with a Yellow background color:


5   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Feb 26 2018 : 14:37:32
No, the changes will push out to the web site with the next update.

Nigel
Xequte Software
www.imageen.com
HeartWare Posted - Feb 26 2018 : 00:42:29
The online help (https://www.imageen.com/help/TIEBitmap.DrawToCanvasWithAlpha.html and https://www.imageen.com/help/TIEBitmap.DrawToCanvas.html) hasn't been changed?
xequte Posted - Feb 25 2018 : 17:20:46
Thanks, I have added a note to the documentation.

Nigel
Xequte Software
www.imageen.com
HeartWare Posted - Feb 23 2018 : 05:12:09
Thank you. I had looked at that method, but thought that it would only use the transparency/opacity given in the call and ignore the one in the bitmap. Perhaps an additional text at the DrawToCanvas to the effect that it doesn't support transparency and to use DrawToCanvasWithAlpha for transparent drawing, and an elaboration in DrawToCanvasWithAlpha, that the specified transparency/opacity values are IN ADDITION to the alpha channel of the source bitmap, ie. an "overlay" on top of the already existing alpha channel.

Anyway - the function works as expected with 255,1 as transparency/opacity. Thank you for the assistance...
w2m Posted - Feb 22 2018 : 11:29:58
TIEBitmap.DrawToCanvasWithAlpha

Declaration

procedure DrawToCanvasWithAlpha(DestCanvas: TCanvas; xDst, yDst : integer; Transparency: integer; Opacity: double);

Description

Draws the whole bitmap to the specified DestCanvas canvas, at coordinates xDst, yDst with parameters:
Transparency specifies the transparency value (0 to 255).
Opacity specifies the opacity (0 to 1.0).

This functions reads the destination canvas pixels and merges them with image using the alpha channel mask.

Note: This is a simplified version of RenderToCanvasWithAlpha

Opacity vs Transparency

Both the Opacity and Transparency parameters provide the same functionality. Transparency is the traditional ImageEn value, whereas Opacity provides easier PSD compatibility.
While they can be used in combination, generally only one will be used, i.e. leave Opacity=1 and make use of transparency, or alternatively, leave Transparency=255 and make use of Opacity. For example, for 50% opacity: Transparency = 255 and Opacity = 0.5, or Transparency = 128 and Opacity = 1.0

procedure TForm1.DrawToCanvasWithAlpha1Click(Sender: TObject);
begin
  ImageEnView1.IEBitmap.DrawToCanvasWithAlpha(ImageEnView2.IEBitmap.Canvas, 10, 10, 255, 1);
  ImageEnView2.Update;
end;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development