Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Black pixels do not load correctly from CMYK JPEGs #8

Open
ghelyar opened this issue Sep 27, 2021 · 0 comments
Open

Black pixels do not load correctly from CMYK JPEGs #8

ghelyar opened this issue Sep 27, 2021 · 0 comments

Comments

@ghelyar
Copy link

ghelyar commented Sep 27, 2021

Version: https://www.nuget.org/packages/BitMiracle.LibJpeg.NET/1.5.324

I created a PNG with 16x16 blocks of Red, Green, Blue, White, Cyan, Magenta, Yellow, Black:
Colours

Then converted it to a CMYK JPEG with ImageMagick:

convert test.png -colorspace cmyk test_cmyk.jpg

test_cmyk

I then used the following code to convert it to a bitmap with BitMiracle LibJpeg.Net:

using (var bitmapStream = File.Create("test.bmp"))
using (var jpegStream = File.OpenRead("test_cmyk.jpg"))
using (var jpeg = new BitMiracle.LibJpeg.JpegImage(jpegStream))
{
    jpeg.WriteBitmap(bitmapStream);
}

This results in the black pixels being loaded as transparent (RGBA of 0xffffff00) rather than black (0x000000ff). I verified this with jpeg.GetRow(y).GetAt(x).GetComponent(c) where y=31, x=63, c=(0, 1, 2, 3) -> (255, 255, 255, 0). This appears white when the alpha channel is stripped, rather than black, which is how everything else displays it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant