Image.Save问题(将CMYK图像保存为CMYK图像)

时间:2009-11-20 01:40:06

标签: winforms tiff cmyk

在Windows窗体应用程序中,我试图打开图像(CMYK tiff),添加文本,然后保存回CMYK tiff图像,但是当我在Photoshop中打开输出图像时,它是RGB图像(颜色)看起来与输入图像不同)。以下是代码,如果您能帮助我,我将不胜感激。

Image^ chartImg = Image::FromFile( "user_chart.tif" );      
Graphics^ g = System::Drawing::Graphics::FromImage(chartImg);

String^ drawString = "Test test test test";
System::Drawing::Font^ drawFont = gcnew System::Drawing::Font("Arial", 9);
System::Drawing::SolidBrush^ drawBrush = gcnew             
System::Drawing::SolidBrush(System::Drawing::Color::Black);
float x = 100.0F;
float y = 10.0F;
System::Drawing::StringFormat^ strFormat = gcnew System::Drawing::StringFormat();
g->DrawString(drawString, drawFont, drawBrush, x, y, strFormat);

chartImg->Save("user_chart2.tif", System::Drawing::Imaging::ImageFormat::Tiff);

1 个答案:

答案 0 :(得分:0)

使用WinForms和GDI +,您尝试做的事情是不可能的。它不包含适当的编码器/解码器来处理CMYK TIFF。

当打开CMYK TIFF时,必须将其转换为RGB,进行更改 - 然后转换回CMYK。

CMYK颜色空间取决于设备,因此您需要使用LibTIFF和LittleCMS将CMYK TIFF读入缓冲区,使用适当的配置文件将其转换为RGB,添加文本并将其转换回来。所有这些都需要使用ICC或ICM配置文件。

可以编写直接写入CMYK TIFF的代码,但它们存储在C,M,Y,K数据的“平面”中。

求助于使用C ++和LibTIFF / LittleCMS的解决方案,你会有更好的运气。

也许另一种选择是WPF,我相信它会打开各种图像编码器/解码器的门,但我不是那么专家。

相关问题