.NET TIFF file: RGB to CMYK conversion possible without a third party library?

╄→尐↘猪︶ㄣ 提交于 2019-11-30 19:24:01

问题


Following up my previous question: if and how would it be possible to take RGB based TIFF files and convert them over to CMYK with standard .NET (3.5) functionality?

Is that possible at all?


回答1:


Actually there is a way using the System.Windows.Media.Imaging namespace which only seems to work properly with TIFFs at the moment (which is fine for me):

    Stream imageStream = new
        FileStream(@"C:\temp\mike4.jpg", FileMode.Open, FileAccess.Read, FileShare.Read);
    BitmapSource myBitmapSource = BitmapFrame.Create(imageStream);
    FormatConvertedBitmap newFormatedBitmapSource = new FormatConvertedBitmap();
    newFormatedBitmapSource.BeginInit();
    newFormatedBitmapSource.Source = myBitmapSource;
    newFormatedBitmapSource.DestinationFormat = PixelFormats.Cmyk32;
    newFormatedBitmapSource.EndInit();

    BitmapEncoder encoder = new TiffBitmapEncoder();
    encoder.Frames.Add(BitmapFrame.Create(newFormatedBitmapSource));

    Stream cmykStream = new FileStream(@"C:\temp\mike4_CMYK.tif",

    FileMode.Create, FileAccess.Write, FileShare.Write);
    encoder.Save(cmykStream);
    cmykStream.Close();

See "Converting images from RGB to CMYK", the answer by Calle Mellergardh.




回答2:


No, I don't think that's possible using standard GDI+ wrappers (System.Drawing). GDI+ only supports RGB. CMYK based images can be read by GDI+ (implicit conversion to RGB), but CMYK based images can't be written.

You might want to try something like GraphicsMill, which supports CMYK.



来源:https://stackoverflow.com/questions/623636/net-tiff-file-rgb-to-cmyk-conversion-possible-without-a-third-party-library

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!