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
 Convert PNG Images to BMPs for using them with Buttons etc.
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

gliden

Germany
2 Posts

Posted - Jul 20 2023 :  04:16:24  Show Profile  Reply
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



xequte

38616 Posts

Posted - Jul 21 2023 :  00:02:01  Show Profile  Reply
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
Go to Top of Page

gliden

Germany
2 Posts

Posted - Jul 21 2023 :  01:19:38  Show Profile  Reply
Hi Nigel,

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

Currently we're using version 11.5.

Dennis
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: