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
 32-bit PNG (RGBA) support
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Eric24

USA
23 Posts

Posted - Mar 23 2013 :  13:08:35  Show Profile  Reply
I have an older version of ImageEn (3.1.2). Is there a known problem with reading 32-bit RGBA PNG files?

Specifically, I'm loading the 32-bit PNG, converting it to grayscale, optionally resamping it, and then saving it as a grayscale PNG. The final result is essentially a corrupted PNG file. It works fine for 8-bit or 24-bit PNGs.

Simplified code snippet:
FoImage.IO.LoadFromFilePNG(Filename);
FoImage.Proc.ConvertToGray;
FoImage.IEBitmap.PixelFormat := ie8g;
FoImage.IO.Params.BitsPerSample := 8;
FoImage.IO.Params.SamplesPerPixel := 1;
FoImage.IO.SaveToFilePNG(Filename);

fab

1310 Posts

Posted - Mar 28 2013 :  12:55:56  Show Profile  Reply
I am not sure, but you should not set PixelFormat=ie8g under 3.1.2. Leave it ie24RGB. The PNG codec will automatically convert the output to 8 bit gray scale (looking at BitsPerSample and SamplesPerPixel).
Go to Top of Page

Eric24

USA
23 Posts

Posted - Mar 28 2013 :  12:58:03  Show Profile  Reply
Perhaps, but it works as-is on all other PNGs (only 32-bit files fail).
Go to Top of Page

fab

1310 Posts

Posted - Mar 28 2013 :  13:15:03  Show Profile  Reply
You're right.
However this problem is still present on current version, and it will be fixed in next minor release.
I cannot patch 3.1.2 version.
Go to Top of Page

Eric24

USA
23 Posts

Posted - Mar 28 2013 :  13:16:53  Show Profile  Reply
No problem. It's not a huge problem (we don't encounter 32-bit PNGs very often). Please let me know when the new release is out and I'll plan to upgrade then.
Go to Top of Page

fab

1310 Posts

Posted - Mar 28 2013 :  13:22:57  Show Profile  Reply
ImageEn updates are notifies in this forum.
Just a stupid hint (but I have to write here...): If you don't need the alpha channel you can remove it running FoImage.RemoveAlphaChannel(). This will produce a non corrupted gray scale PNG.
Go to Top of Page

Eric24

USA
23 Posts

Posted - Mar 28 2013 :  13:24:45  Show Profile  Reply
Actually, that's a pretty good idea. I'll try it. Thanks!
Go to Top of Page

MTW

Italy
1 Posts

Posted - Mar 10 2016 :  05:09:56  Show Profile  Reply
Hello,
I have version 6.0.0, when I convert to grayscale (ie8g) and try to save to file, I get a monochrome image!!

here is my code:

  ImageEnView1.IO.LoadFromFileAuto('d:\test_image_24RGB.jpg');
  ImageEnView1.IEBitmap.PixelFormat := ie8g;
  ImageEnView1.IEBitmap.Write('d:\test_image_8g.png');


I took a look into TIEBitmap.Write and I saw:

ie8g:
          begin
            io.Params.BitsPerSample := 1;
            io.Params.SamplesPerPixel := 1;
            io.Params.JPEG_ColorSpace := ioJPEG_GRAYLEV;
          end;


but, shouldn't be io.Params.BitsPerSample := 8?
I have tried to modify the source and it seems to work..

I have also added defaults for J2000 and TGA (just in case):
io.Params.J2000_ColorSpace := ioJ2000_GRAYLEV;
io.Params.TGA_GrayLevel := true;


Is this problem addressed in 6.2.2?

thank you in advance
Matteo
Go to Top of Page

xequte

39052 Posts

Posted - Mar 13 2016 :  22:54:59  Show Profile  Reply
Hi Matteo

I'm afraid that is not fixed until 6.2.3.

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