mono / SkiaSharp

SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.
MIT License
4.14k stars 522 forks source link

[BUG] SKBitmap.ColorSpace is always null. Unable to check for CMYK, RGB, etc. #2849

Open dsyno opened 3 weeks ago

dsyno commented 3 weeks ago

Description

Our code needs to check whether an image is CMYK or RGB (and reject any image that is CMYK).

However, @mattleibow "explicitly set the color space to null for backwards compatibility". That is breaking things, since it now seems to be impossible (without jumping through major hoops) to check whether an image is CMYK or not.

Solution: Allow ColorSpace to return the correct value. Or provide another method for checking the color space.

Code

SKBitmap.ColorSpace

Expected Behavior

SKBitmap.ColorSpace should return correct value, instead of null.

Actual Behavior

SKBitmap.ColorSpace always returns null.

Version of SkiaSharp

2.88.3 (Current)

Last Known Good Version of SkiaSharp

Other (Please indicate in the description)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

All

Platform / Operating System Version

All

Devices

All

Relevant Screenshots

No response

Relevant Log Output

No response

Code of Conduct

mattleibow commented 2 weeks ago

We could remove that for 3.0.

You could use SKImage as well - or use SKCodec directly and SKBitmap.Decode. That will not remove the colorspace.