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
 Convert PNG Images to BMPs for using them with Buttons etc.

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
gliden Posted - Jul 20 2023 : 04:16:24
Hi,

we have some png-images which we want to convert to bmps using ImageEN.
These images have an alpha channel which should be converted to clFuchsia using
ImageEnView1.IEBitmap.RemoveAlphaChannel(true, clFuchsia);


But the image border should be a different color so Delphi draws the image correct.
How could I achieve this?

I attach the original png-image (yeah, it's white...), the result generated by ImageEn and an image generated by a third party programm.

attach/gliden/202372041528_camera.png



2   L A T E S T    R E P L I E S    (Newest First)
gliden Posted - Jul 21 2023 : 01:19:38
Hi Nigel,

thank you for your help. Now it's the expected result.

Currently we're using version 11.5.

Dennis
xequte Posted - Jul 21 2023 : 00:02:01
Hi

What version of ImageEn are you using? When I use:

  ImageEnView1.IO.LoadFromFile( 'D:\camera.png' );
  ImageEnView1.IEBitmap.RemoveAlphaChannel( True, clFuchsia );
  ImageEnView1.IO.SaveToFile( 'D:\camera.bmp' );


I get the same as the second image, which is what I would expect.



Which is not actually a suitable image because the background color has been merged with the anti-aliasing, so displayed on screen it will look like this:



Unfortunately this problem (going from full alpha to 1bit alpha) is not an easy one to solve (whether with ImageEn or any third party editor). You are always going to be left with ugly "jaggies". The best solution is to merge with a suitable anti-aliasing color (similar to the expected background color of the destination, e.g. light gray) and then set that color to fuchsia.

const
  Anti_Aliasing_Color = $00C9C9C9; // Light gray
begin
  ImageEnView1.IO.LoadFromFile( 'D:\camera.png' );

  // Merge alpha with our background color
  ImageEnView1.IEBitmap.RemoveAlphaChannel( True, Anti_Aliasing_Color );

  // Convert our background color pixels to fuchsia
  ImageEnView1.Proc.CastColorRange( Anti_Aliasing_Color, Anti_Aliasing_Color, clFuchsia );

  ImageEnView1.IO.SaveToFile( 'D:\camera2.bmp' );
end;



Nigel
Xequte Software
www.imageen.com