new Bitmap image with CMYK

The "duplicate" question explains how to change RGB to CMYK for a single value. I need to change an Image object and you can't convert it pixel by pixel, because you need a Bitmap object for it. If I change the Image object to Bitmap it's already converted, but with bad quality.

I have been using the same resize method for jpg images for ages, but today I noticed that some images have very bad quality.

        var newImage = new Bitmap(width, height);
        using (Graphics gr = Graphics.FromImage(newImage))
        {
            gr.SmoothingMode = SmoothingMode.HighQuality;
            gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
            gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
            gr.DrawImage(image, new Rectangle(0, 0, width, height));
        }

        //return image;
        return newImage;

Keep in mind that i'm not resizing anything at this point. If i return image the quality is like the original and if I return newImage the colors are very dull.

When you open the "bad" image in Photoshop, the image has a CMYK mode. If I change it to RGB in Photoshop and try again the colors stay the same.

I can detect the CMYK in C# , but I have no idea on how to alter the newImage object to keep the colors correct.

I tried to set the palette of newImage to the palette of image , but this throws an invalid parameter exception. I also tried to create the bitmap directly from the original with new Bitmap(image, new Size(width, height)); but this doesnt change anything.

I also tried to load the Graphics gr directly from the original image with Graphics gr = Graphics.FromImage(image) but this throws an Out of memory exception.

Example images are smaller then the original, but you can still see the quality difference.

CMYKRGB

How can I change CMYK to RGB in c# without quality loss?

链接地址: http://www.djcxy.com/p/50294.html

上一篇: 在C ++中将彩色位图转换为灰度

下一篇: 带有CMYK的新位图图像