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
 TImageEnView Load (png 24bit image), Save (png 8bit paleted white transparency
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

andyhill

Australia
133 Posts

Posted - Sep 04 2021 :  18:26:10  Show Profile  Reply
ColorPalette:= TIEColorPalette.Create(nil);

ie:= TImageEnView.Create(nil);
//ie.LegacyBitmap:= True;
ie.IO.NativePixelFormat:= True;
//ie.EnableAlphaChannel:= True;
ie.IO.LoadFromFilePng(UniServerModule.EXEDir+'temp\temp.png');

if ie.IEBitmap.PixelFormat <> ie8p then begin
  ie.IEBitmap.PixelFormat:= ie8p; // FAILS TO CHANGE
end;

ColorPalette.AssignPalette(ie, False, True);
ie.IEBitmap.SetTransparentColors(clWhite, clWhite, 0);
ColorPalette.Free;


Please advise how to LoadFromFilePng, SaveToFilePng (8bit paleted with white transparent background) - thanks

I want to save ie to a PNG File with a White Transparent Background (8bit preferable but 24bit is OK too).

Andy

xequte

38182 Posts

Posted - Sep 06 2021 :  00:48:52  Show Profile  Reply
Hi Andy

Do you mean like this:

  // Convert a 32bit PNG file to an 8bit PNG (without transparency)

  ImageEnView1.IO.LoadFromFile( 'D:\Alpha.png');

  // Remove alpha channel and make background white
  ImageEnView1.IEBitmap.RemoveAlphaChannel( True, clWhite );

  // Set PixelFormat to 8bit
  ImageEnView1.IEBitmap.PixelFormat := ie8p;

  // Use PixelFormat as authoritative source of bit-depth
  IEGlobalSettings().AutoSetBitDepth := True;

  ImageEnView1.IO.SaveToFile('D:\No-Alpha.png');


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

andyhill

Australia
133 Posts

Posted - Sep 06 2021 :  01:10:36  Show Profile  Reply
I want Transparency.

When ever I resample (scale) I loose transparency.

Please show me how to load JPG/PNG file (assume 24bit) - Save as PNG file with transparency.

Jpg-24bit ---> Resample (downsize) ---> Png-8bit (with White Transparency).



Andy
Go to Top of Page

xequte

38182 Posts

Posted - Sep 06 2021 :  03:54:46  Show Profile  Reply
Hi Andy

Only a 32bit PNG file supports alpha, so are you wanting to turn the white pixels transparent and then save as a transparent PNG?

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

andyhill

Australia
133 Posts

Posted - Sep 06 2021 :  16:09:28  Show Profile  Reply
I use Corel PhotoPaint and it can make PNG Transparent Images on a few formats including 8bit Paleted ?

Andy
Go to Top of Page

xequte

38182 Posts

Posted - Sep 06 2021 :  18:30:19  Show Profile  Reply
Hi Andy,

Sorry, to be clear only 32bit PNG (and 8bit grayscale PNG) support full alpha transparency.

8bit color PNG can support 1bit transparency (i.e. not alpha).

Though in my tests today, I encountered an issue with that, so we'll need to investigate further.



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

andyhill

Australia
133 Posts

Posted - Sep 06 2021 :  19:48:56  Show Profile  Reply
I have had issues hence my posting so I am glad you have found something to fix :)

Andy
Go to Top of Page

andyhill

Australia
133 Posts

Posted - Sep 06 2021 :  22:07:32  Show Profile  Reply
I have wrestled with this problem for a very long time ...

WHENEVER I use TImageEnView to ReSample a PNG Image the PNG Image Pallet (transparency color goes haywire) resulting in BLACK Image.

Please provide work around ASAP (it is urgent) - Thank You


Andy
Go to Top of Page

xequte

38182 Posts

Posted - Sep 08 2021 :  04:11:22  Show Profile  Reply
Hi Andy

I used the code and source you sent. It produces a valid image for me.

What version of Delphi are you using?

Are you creating a 32bit or 64bit EXE? If 64bit, what is the value of:

IEGlobalSettings().ActivePngEngine();



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

andyhill

Australia
133 Posts

Posted - Sep 08 2021 :  04:47:15  Show Profile  Reply
IEGlobalSettings().ActivePngEngine();

Does not work on its own, please show code as to how to implement and what to set it for 64bit applications ?.

Andy
Go to Top of Page

xequte

38182 Posts

Posted - Sep 08 2021 :  05:58:45  Show Profile  Reply
Hi Andy

IEGlobalSettings().ActivePngEngine just shows what engine is being used. If you have not added ielib64.dll to your exe folder, then it will be ieWIC. Is the problem resolved if you use ielib64.dll?

https://www.imageen.com/help/TIEImageEnGlobalSettings.PNGEngine.html
https://www.imageen.com/help/TIEImageEnGlobalSettings.ActivePNGEngine.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

xequte

38182 Posts

Posted - Oct 12 2021 :  22:37:39  Show Profile  Reply
We have fixed the issue of 8bit color PNG not supporting 1bit transparency.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: