2015-09-14 47 views
1

鉴于这种拱形文本图像,在透明背景上的黑色像素,抗锯齿创建CMYK +阿尔法位图,映射黑到特定CMYK颜色

arched text, RGB black on transparent

我将最终喜欢这个文本的CMYK渲染,每一个黑色像素都会变成特定的CMYK颜色,比如洋红色或{72,36,9,28},或者我的客户指定的任何颜色。最终的输出将是PDF。每个透明像素都需要保持透明,因为文本下可能还有其他PDF对象。

我会满足于将CMYK + Alpha TIFF等效写入磁盘。或者,可能是System.Windows.Media.Imaging.Bitmapimage。或者是其他东西。

我的PDF库是ABCpdf.NET 10.我意识到System.Drawing不支持CMYK颜色格式。我可以和其他第三方库一起使用;我已经在图书馆的另一个环境中使用了AForge。

我是不是寻找RGB到CMYK转换,甚至没有配置文件。我是而不是希望在PDF中进行通用颜色替换。我的客户将指定明确的CMYK目标颜色,并且我需要完全匹配它;在RGB近似上使用颜色转换是不行的。

我已经摆脱了各种各样的东西。我所得到的最接近的颜色是在RGB模式下交换颜色 - 黑色变为透明,透明变为白色 - 并在图像下绘制一个填充的洋红色框。然后在没有文字的地方绘制白色像素,并在下方显示洋红色。作为一个团体来看,这最终看起来像白色扭曲的洋红色文本。但是任何坐在这个组里的东西都不会透露出来。 link

任何想法?

回答

0

websupergoo的Jos Vernon想出了一个使用ABCpdf功能的出色简单答案。

using WebSupergoo.ABCpdf10; 
using WebSupergoo.ABCpdf10.Objects; 

namespace RecolorRenderedImage 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      using (Doc theDoc = new Doc()) { 
       // this background image is there to prove that the text is not obscuring other pdf objects 
       theDoc.AddImage("c:\\temp\\background-pic.jpg"); 

       // this is the black warped text 
       string fullFilePath = "c:\\temp\\foobar.png"; 

       // read it into an XImage. Add to the doc, and retrieve the pixmap 
       XReadOptions readOptions = new XReadOptions(); 
       XImage image = XImage.FromFile(fullFilePath, readOptions); 
       int theID = theDoc.AddImageObject(image, true); 
       int imageID = theDoc.GetInfoInt(theID, "XObject"); 
       PixMap thePM = (PixMap)theDoc.ObjectSoup[imageID]; 

       // recolor the pixmap temporary spot color space with the desired color (gold in this case) 
       int spotColorID = theDoc.AddColorSpaceSpot("tempSpace", "24 44 100 2"); 
       ColorSpace theSP = (ColorSpace)theDoc.ObjectSoup[spotColorID]; 
       thePM.Recolor(theSP); 

       // immediately recolor the pixmap back to CMYK 
       ColorSpace theSP2 = new ColorSpace(theDoc.ObjectSoup, ColorSpaceType.DeviceCMYK); 
       thePM.Recolor(theSP2); 

       theDoc.Save("c:\\temp\\test.pdf"); 
      } 
     } 

    } 
} 

output file黄金文字在图片