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
 Load a PNG file and copy it to a Bitmap

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
DRIGUS Posted - Mar 05 2019 : 04:38:20
Hi *.*.

I use ImageEn (8.3.0) and try to load a PNG file and copy it to a Graphics.TBitmap for further processing. The transparent parts of the PNG file should have a user defined color. I tried the following:


  Buffer := Graphics.TBitmap.Create;
  ImageIO := TImageEnIO.Create(nil);
  ImageIO.AttachedBitmap := Buffer;
  ImageIO.Background := aBackgroundColor; // f.e. clWhite
  ImageIO.LoadFromFile(FileName);


But the transparent parts are always black. How can I define the color for the transparent parts of the PNG?


Greetrings
6   L A T E S T    R E P L I E S    (Newest First)
DRIGUS Posted - Mar 08 2019 : 02:41:48
Thanks for the fast and excellent support.


Greetings
xequte Posted - Mar 07 2019 : 15:08:10
Hi

That is fine too.



Nigel
Xequte Software
www.imageen.com
DRIGUS Posted - Mar 07 2019 : 03:07:40
This is what I already do. But I do it without creating a TIEBitmap:


  ImageIO := tImageEnIO.Create(nil);
  ImageIO.OnProgress := SetProgress;
  ImageIO.LoadFromFile(FileName);
  Buffer := Graphics.tBitmap.Create;
  if ImageIO.IEBitmap.HasAlphaChannel then
    ImageIO.IEBitmap.RemoveAlphaChannel(True, clWhite);
  ImageIO.IEBitmap.CopyToTBitmap(FPrnBuffer);
  ImageIO.Free;


I saw that there is a


  fIEBitmap := TIEBitmap.Create;


in TImageEnIO.Create. Is this O.K. or should I always attach a TIEBitmap by myself?


Greetings
xequte Posted - Mar 06 2019 : 22:48:20
Hi

In the next version TIEBitmap will have a progress event, but you can use:


// Load a transparent PNG, remove the alpha channel (merging with a white background). Then assign it to a TBitmap
aBmp := TIEBitmap.Create;
ImageIO := TImageEnIO.Create(nil);
ImageIO.AttachedBitmap := aBmp;
ImageIO.LoadFromFile(FileName);
aBmp.RemoveAlphaChannel( True, clWhite );
aBmp.CopyToTBitmap( MyTBitmap );
ImageIO.Free;
aBmp.free;


Nigel
Xequte Software
www.imageen.com
DRIGUS Posted - Mar 06 2019 : 04:21:28
This works, thanks. I only query HasAlphaChannel before removing the alpha channel because I have to load a wide range of image files and still use TImageEnIO in order to receive the OnProgress event.


Greetings
xequte Posted - Mar 05 2019 : 16:57:37
Hi

Rather than use a TBitmap to handle the alpha, which can be problematic, use a TIEBitmap.

// Load a transparent PNG, remove the alpha channel (merging with a white background). Then assign it to a TBitmap
aBmp := TIEBitmap.Create;
aBmp.Read('D:\TransparentImage.png');
aBmp.RemoveAlphaChannel( True, clWhite );
aBmp.CopyToTBitmap( MyTBitmap );
aBmp.free;


Nigel
Xequte Software
www.imageen.com