Comments (3)
Thank you for the report. I'm aware about the issue and I plan to extend the new KnownPixelFormat
enum (so far available as a preview in KGySoft.Drawing.Core, which is the new package of the platform and technology-independent APIs) with a new Format32bppCmyk
field so CMYK format will be natively supported.
As I already implemented CMYK format for WPF (also in preview so far) it will not be a big deal even for the Core package.
However, GDI+ Bitmap
is a bit different. Its CMYK support is actually quite a hack: it uses an unnamed System.Drawing.Imaging.PixelFormat
value (8207) and is not supported on all platforms. Actually you can open the posted image even in my ImagingTools: in Windows Vista or above you will see 8207
as the displayed pixel format. Windows XP behaves differently though: CMYK JPEG images are loaded with Format24bppRgb
pixel format, and CMYK TIFF images with Format32bppArgb
format (if the source image uses 8 bits for each channel).
What you can expect from me:
I was already planning to add CMYK support also to KGySoft.Drawing (starting with 7.0.0 this contains only the GDI+ specific APIs) but maybe only as source format. Meaning, ImageExtensions.ConvertPixelFormat
will support it as source format but (probably) not as a target format.
What you can do today:
If you need to use CMYK source images you can try the following workarounds today:
- Use WPF's
WriteableBitmap
to load the source image, and then access it byWriteableBitmapExtensions.GetReadWriteBitmapData
, where I already implemented CMYK support (requires the KGySoft.Drawing.Wpf package). Then you can use theClone
extension methods that have apixelFormat
parameter, which are essentially the same as theConvertPixelFormat
methods for GDI+ images. The convertedIReadWriteBitmapData
can be converted to a GDI+Bitmap
by theToBitmap
extension method. - Even the last stable release allows you to use custom pixel formats. For a native GDI+
Bitmap
you can use theLockBits
method, and then the buffer is exposed by theBitmapData.Scan0
property as you can see here (the solution should be something similar to the WPF version linked above). This way you will have anIReadWriteBitmapData
so the rest is the same as in the previous point with cloning, etc. - Save your CMYK images in TIFF format using 16 bits-per-channel. Such a
Bitmap
is loaded withFormat48bppRgb
pixel format by the TIFF decoder (at least in Windows Vista and above) so you can useConvertPixelFormat
as expected.
from kgysoft.drawing.
Thanks for the quick response! My current usage requirement is only as a source input to ConvertPixelFormat(), so 'source only' is fine.
My workaround is to convert the cmyk image to rgb thusly:
public static Bitmap AsRgb(this Bitmap img) { if (((int) img.PixelFormat) != 8207) { //8207 == PixelFormat.Cmyk32 return img; } try { return img.To24bppRgb(); } finally { img.Dispose(); } }
from kgysoft.drawing.
The CMYK support of Bitmap
(only as input format) has been released in 7.0.0-preview.2 (see the change log)
from kgysoft.drawing.
Related Issues (10)
- Conversion of Format8bppIndexed image to gray fails (rather subtly) HOT 4
- Can't update to System.Drawing.Common version 6.0.0 HOT 2
- Please avoid using the Lena image as an example HOT 3
- Fast image width and height HOT 2
- ImageExtensions.GetBitsPerPixel() return value always be 32 HOT 1
- Ditherer parameter not optional? HOT 2
- EntryPointNotFoundException: Unable to find an entry point named 'RtlCopyMemory' in DLL 'kernel32.dll'. HOT 7
- Already quantized frames are processed again and not dithered on save HOT 34
- Question HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kgysoft.drawing.