用颜色覆盖 WriteableBitmap

发布于 2024-08-24 05:33:41 字数 967 浏览 6 评论 0 原文

我正在尝试在 Silverlight 中用某种颜色覆盖 WriteableBitmap。我有一个黑白基本图像,我用它来为新的合成图像创建较小的 WriteableBitmap 图像,并且我想在将其添加到之前用某种颜色覆盖源图像剪切的黑色或白色部分合成图像。

我现在正在做的是:

var cutOut = new WriteableBitmap(8, 14);
/*
    cut out the image here
*/
cutOut.Render(sourceImage, transform); // sourceImage is the base image
cutOutImage.Source = cutOut; // cutOutImage is an Image element in XAML

compositeImage.Render(cutOutImage, transform2); // compositeImage is the final WriteableBitmap that is shown on screen

我尝试了 http://blogs.silverarcade.com/silverlight-games-101/15/silverlight-blitting-and-blending-with-silverlights-writeablebitmap/ 并使用来自的扩展方法hxxp://writeablebitmapex.codeplex.com/,但在将其渲染到compositeImage之前,我似乎无法在cutOut图像上获得颜色叠加。

有谁知道有一个好的方法来做到这一点?

提前致谢。

I'm trying to overlay a WriteableBitmap with a certain color in Silverlight. I have a black and white base image, which I'm using to create smaller WriteableBitmap images for a new composite image and I want to overlay either the black or white part of the source image cut-out with a certain color before adding it to the composite image.

What I'm doing now is:

var cutOut = new WriteableBitmap(8, 14);
/*
    cut out the image here
*/
cutOut.Render(sourceImage, transform); // sourceImage is the base image
cutOutImage.Source = cutOut; // cutOutImage is an Image element in XAML

compositeImage.Render(cutOutImage, transform2); // compositeImage is the final WriteableBitmap that is shown on screen

I tried the methods on http://blogs.silverarcade.com/silverlight-games-101/15/silverlight-blitting-and-blending-with-silverlights-writeablebitmap/ and using the extension methods from hxxp://writeablebitmapex.codeplex.com/, but I cannot seem to get a color overlay on the cutOut image before rendering it to the compositeImage.

Does anyone know of a good method to do this?

Thanks in advance.

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

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

发布评论

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

评论(1

末蓝 2024-08-31 05:33:41

只是一个快速猜测,但是您在执行 WriteableBitmap.Render(...) 之后尝试过使用 WriteableBitmap.Invalidate() 吗?
除此之外,您可能想尝试将图像渲染到临时 WriteableBitmap,然后使用 WriteableBitmap.Pixels 将该临时图像复制到新位图上。在该新位图上,您应该能够执行图像操作。

干杯,亚历克斯

just a quick guess, but have you tried playing around with WriteableBitmap.Invalidate() after doing WriteableBitmap.Render(...)?
Apart from that, you might want to try rendering your image to a temporary WriteableBitmap and then copy that temporary one onto a new bitmap using WriteableBitmap.Pixels. On that new bitmap, you should be able to perform image manipulations.

Cheers, Alex

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