是否有一种技术可以将图像重新抗锯齿为不同的背景颜色?

发布于 2024-09-14 23:47:36 字数 70 浏览 3 评论 0原文

是否有一种编程方法可以在新的背景颜色/图案上绘制抗锯齿图像,从而将图像重新抗锯齿为新的背景颜色?最好可以访问 .Net 程序?

Is there a programmatic approach for drawing an anti-aliased image on a new background color / pattern that would re-anti-alias the image to the new background color? Preferably accessible to a .Net program?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

肤浅与狂妄 2024-09-21 23:47:36

您可以使用 WPF 创建新图像并将其保存到图像文件中。

You can use WPF to create the new image and save it out to an image file.

掀纱窥君容 2024-09-21 23:47:36

如果图像已经针对特定背景颜色进行了抗锯齿处理,那么在代码中自动删除此抗锯齿处理将很困难 - 不幸的是,最好的选择是手动编辑图像。

If an image has already been anti-aliased against a particular background colour then removing this anti-aliasing automatically will prove difficult in code - your best bet is to manually edit the image, unfortunately.

王权女流氓 2024-09-21 23:47:36

一般情况下是没有办法做到的。但如果你稍微限制一下你的要求,这是可以做到的。

如果我们假设抗锯齿图像是我们已知的纯色,并且我们将背景作为单独的文件,我可以告诉您如何做到这一点。

例如,假设抗锯齿图像由某种黑色字体的单词组成。而且背景是任意的。然后,要为另一个背景“重新抗锯齿”图像,您需要两个步骤:

  1. 恢复与背景隔离的原始抗锯齿图像。为此,请执行此算法:

    for_every_pixel {
    isolated_pixel_intensity = 1 - rgb_distance(mixed_pixel_rgb - background_pixel_rgb, foreground_solid_rgb)
    }
    // rgb_distance 在 3D 中被实现为勾股定理。

  2. 现在您已经有了前景图像,只需将其与新背景混合即可。

您必须自己编写代码。由于您使用的是 .NET,因此可以使用 System.Drawing.Bitmap 作为基础。

编辑:忽略这一点。它实际上是行不通的,因为有些情况是无法解决的——即,当背景图像包含与前景颜色相同的区域时。

There is no way to do it in the general case. But if you limit your requirements a bit, it can be done.

I can tell you how to do it if we assume the anti-aliased image is of a solid color known to us, and we have the background as a separate file.

For example let's say the anti-aliased image consists of a word in some font, in black. And the background is arbitrary. Then, to "re-antialias" the image for another background, you need two steps:

  1. Recover the original anti-aliased image, isolated from the background. To do this, perform this algorithm:

    for_every_pixel {
    isolated_pixel_intensity = 1 - rgb_distance(mixed_pixel_rgb - background_pixel_rgb, foreground_solid_rgb)
    }
    // rgb_distance is implemented as Pythagora's Theorem in 3D.

  2. Now that you have the foreground image, simply blend it with your new background.

You'd have to write the code yourself. You can use System.Drawing.Bitmap as a basis since you're using .NET.

Edit: Disregard this. It can't actually work, because there are cases that are impossible to solve - namely, when the background image contains areas of the same color as the foreground.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文