libgdiplus icon indicating copy to clipboard operation
libgdiplus copied to clipboard

PixelFormat Tiff CcittGr4 wrong on linux

Open gjmv opened this issue 5 years ago • 5 comments

Hi, i'm working with Tiff CCITTGr4 images (bitonal) and when i test in linux (net core 2.2/3.0/3.1 - libgdiplus: 4.2-1+b1) the Bitmap class give me PixelFormat.Format24bppRgb When i run in windows, PixelFormat give me Format1bppIndexed (the correct value). I've tested in mono (docker) and get wrong value too.

The test code is very simple. Having test.tif file (TIF CCITTGr4) using (Bitmap bmp = new Bitmap("test.tif")) { Console.WriteLine(bmp.PixelFormat); }

I've opened it in dotnet/runtime and them have redirected me here. https://github.com/dotnet/runtime/issues/1106

Regards Gustavo

gjmv avatar Dec 21 '19 13:12 gjmv

Can you give the latest libgdiplus version (6.0.4) or master a try? A bunch of issues have been fixed recently.

qmfrederik avatar Dec 21 '19 14:12 qmfrederik

Can you give the latest libgdiplus version (6.0.4) or master a try? A bunch of issues have been fixed recently.

Hi, I tested in mono docker too (i didn't realize libgdiplus version). In this container version is: libgdiplus Installed: 6.0.4-0xamarin1+debian9b1 Same problem PixelFormat=Format24bppRgb

Regards

gjmv avatar Dec 21 '19 14:12 gjmv

Here's a link to the relevant code that does the conversion to RGB24/32:

https://github.com/mono/libgdiplus/blob/e064a4c90c4f472ca81d8d4e1297c5bc18541842/src/tiffcodec.c#L1130-L1137

Any loaded TIFF currently ends up being converted to one of those formats.

filipnavara avatar Dec 22 '19 23:12 filipnavara

Here's a link to the relevant code that does the conversion to RGB24/32:

https://github.com/mono/libgdiplus/blob/e064a4c90c4f472ca81d8d4e1297c5bc18541842/src/tiffcodec.c#L1130-L1137

Any loaded TIFF currently ends up being converted to one of those formats.

Yes, today i was reading the code. I think that is a libtiff characteristic, about how it load the image in memory. It converts 1bpp to RGB https://gitlab.com/libtiff/libtiff/blob/master/libtiff/tif_getimage.c#L1378-1393 I think it has no solution.

I need to know if the image loaded is B&W (1bpp) or not. But I need a solution that works with all formats. In Windows, PixelFormat do this, but when I migrated to dotnet core, and tested in linux, found this issue.

Thanks anyway

gjmv avatar Dec 23 '19 01:12 gjmv

Hi, I am wondering if there has been any updates related to this issue? I am running into a similar issue writing text onto a Format1bppIndexed image. On Windows this works just fine, but on Linux it is converting the image to Format24bppRgb.

If there are no plans to resolve this, are there any recommendations I should try to work around this issue?

chrisheil avatar Dec 03 '20 17:12 chrisheil