鉴于这一拱形文本图像,黑色像素在透明的背景下,具有抗混叠性。

我最终想要这个文本的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中交换颜色--黑色变成透明,透明变成白色--然后在图像下面画一个装满了的洋红色盒子。然后画出文字不在的地方的白色像素,下面的洋红色显示出来。作为一个整体,这看起来就像白色上扭曲的洋红色文本。但是,坐在小组下面的任何东西都不会露出来。链接
有什么想法吗?
发布于 2015-09-14 22:41:28
websupergoo的Jos提出了一个非常简单的解决方案,它使用了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");
}
}
}
}延迟编辑:删除到输出文件的链接,因为我在某个时候从GDrive中删除了它。
https://stackoverflow.com/questions/32569740
复制相似问题