mono / libgdiplus

C-based implementation of the GDI+ API
http://www.mono-project.com/
MIT License
334 stars 171 forks source link

PixelFormat Tiff CcittGr4 wrong on linux #616

Open gjmv opened 4 years ago

gjmv commented 4 years ago

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

qmfrederik commented 4 years ago

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

gjmv commented 4 years ago

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

filipnavara commented 4 years ago

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.

gjmv commented 4 years ago

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

chrisheil commented 3 years ago

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?