热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

创建CMYK+alpha位图,将黑色映射到特定的CMYK颜色-CreateCMYK+alphabitmap,mappingblacktospecificCMYKcolor

Giventhisarchedtextimage,blackpixelsontransparentbackground,withantialiasing给定这个拱形文本图像,透

Given this arched text image, black pixels on transparent background, with antialiasing

给定这个拱形文本图像,透明背景上的黑色像素,具有抗锯齿功能

arched text, RGB black on transparent

I would ultimately like to have a CMYK rendering of this text, where every black pixel becomes a specific CMYK color, say magenta, or {72,36,9,28}, or whatever my customer specifies. The ultimate output will be PDF. Every transparent pixel needs to remain transparent, as there may be other PDF objects under the text.

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

I would be content with a CMYK+Alpha TIFF equivalent written to disk. Or, possibly, a System.Windows.Media.Imaging.Bitmapimage. Or something else.

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

My PDF library is ABCpdf.NET 10. I realize that System.Drawing does not support CMYK color format. I'm ok with other third party libraries; I'm already using AForge in another context in the library.

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

I am not looking to do RGB to CMYK conversion, not even with a profile. I am not looking to do generic color replacement in a PDF. My customer will specify a definite CMYK target color, and I need to match it exactly; using color conversion on an RGB approximation is not okay.

我不打算做RGB到CMYK转换,甚至没有配置文件。我不打算在PDF中进行通用颜色替换。我的客户将指定一个明确的CMYK目标颜色,我需要完全匹配它;在RGB近似上使用颜色转换是不可行的。

I've flailed around with various things. The closest I got was to swap the colors while staying in RGB -- black becomes transparent, transparent becomes white -- and draw a filled magenta box under the image. That then draws white pixels where the text is not, and the magenta underneath shows through. Considered as a group, this ends up looking like warped magenta text on white. But anything sitting under the group does not show through. link

我已经挥舞着各种各样的东西。我得到的最接近的是交换颜色,同时保持RGB - 黑色变为透明,透明变为白色 - 并在图像下绘制一个填充的洋红色框。然后绘制白色像素,文本不是,下面的洋红色显示通过。被视为一个群体,这最终看起来像白色扭曲的洋红色文字。但是,任何坐在小组下面的东西都没有显示出来。链接

Any ideas?

1 个解决方案

#1


0  

Jos Vernon at websupergoo came up with a splendidly simple answer that uses ABCpdf capabilities.

在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 with gold text over a picture

输出文件与图片上的金色文字


推荐阅读
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 本文讨论了使用差分约束系统求解House Man跳跃问题的思路与方法。给定一组不同高度,要求从最低点跳跃到最高点,每次跳跃的距离不超过D,并且不能改变给定的顺序。通过建立差分约束系统,将问题转化为图的建立和查询距离的问题。文章详细介绍了建立约束条件的方法,并使用SPFA算法判环并输出结果。同时还讨论了建边方向和跳跃顺序的关系。 ... [详细]
  • ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction ... [详细]
  • Python正则表达式学习记录及常用方法
    本文记录了学习Python正则表达式的过程,介绍了re模块的常用方法re.search,并解释了rawstring的作用。正则表达式是一种方便检查字符串匹配模式的工具,通过本文的学习可以掌握Python中使用正则表达式的基本方法。 ... [详细]
  • Java学习笔记之面向对象编程(OOP)
    本文介绍了Java学习笔记中的面向对象编程(OOP)内容,包括OOP的三大特性(封装、继承、多态)和五大原则(单一职责原则、开放封闭原则、里式替换原则、依赖倒置原则)。通过学习OOP,可以提高代码复用性、拓展性和安全性。 ... [详细]
  • Go Cobra命令行工具入门教程
    本文介绍了Go语言实现的命令行工具Cobra的基本概念、安装方法和入门实践。Cobra被广泛应用于各种项目中,如Kubernetes、Hugo和Github CLI等。通过使用Cobra,我们可以快速创建命令行工具,适用于写测试脚本和各种服务的Admin CLI。文章还通过一个简单的demo演示了Cobra的使用方法。 ... [详细]
  • 使用C++编写程序实现增加或删除桌面的右键列表项
    本文介绍了使用C++编写程序实现增加或删除桌面的右键列表项的方法。首先通过操作注册表来实现增加或删除右键列表项的目的,然后使用管理注册表的函数来编写程序。文章详细介绍了使用的五种函数:RegCreateKey、RegSetValueEx、RegOpenKeyEx、RegDeleteKey和RegCloseKey,并给出了增加一项的函数写法。通过本文的方法,可以方便地自定义桌面的右键列表项。 ... [详细]
  • 生成式对抗网络模型综述摘要生成式对抗网络模型(GAN)是基于深度学习的一种强大的生成模型,可以应用于计算机视觉、自然语言处理、半监督学习等重要领域。生成式对抗网络 ... [详细]
  • 本文主要解析了Open judge C16H问题中涉及到的Magical Balls的快速幂和逆元算法,并给出了问题的解析和解决方法。详细介绍了问题的背景和规则,并给出了相应的算法解析和实现步骤。通过本文的解析,读者可以更好地理解和解决Open judge C16H问题中的Magical Balls部分。 ... [详细]
  • 推荐系统遇上深度学习(十七)详解推荐系统中的常用评测指标
    原创:石晓文小小挖掘机2018-06-18笔者是一个痴迷于挖掘数据中的价值的学习人,希望在平日的工作学习中,挖掘数据的价值, ... [详细]
  • 怀疑是每次都在新建文件,具体代码如下 ... [详细]
  • 本文详细介绍了Java中vector的使用方法和相关知识,包括vector类的功能、构造方法和使用注意事项。通过使用vector类,可以方便地实现动态数组的功能,并且可以随意插入不同类型的对象,进行查找、插入和删除操作。这篇文章对于需要频繁进行查找、插入和删除操作的情况下,使用vector类是一个很好的选择。 ... [详细]
  • HTML学习02 图像标签的使用和属性
    本文介绍了HTML中图像标签的使用和属性,包括定义图像、定义图像地图、使用源属性和替换文本属性。同时提供了相关实例和注意事项,帮助读者更好地理解和应用图像标签。 ... [详细]
  • 开发笔记:实验7的文件读写操作
    本文介绍了使用C++的ofstream和ifstream类进行文件读写操作的方法,包括创建文件、写入文件和读取文件的过程。同时还介绍了如何判断文件是否成功打开和关闭文件的方法。通过本文的学习,读者可以了解如何在C++中进行文件读写操作。 ... [详细]
  • 本文整理了Java中org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc.getTypeInfo()方法的一些代码示例,展 ... [详细]
author-avatar
丝兰郁香
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有