我正在尝试在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图像上获得颜色覆盖。
有人知道这样做的好方法吗?
提前致谢。
最佳答案
只是一个快速的猜测,但是您在执行WriteableBitmap.Render(...)之后是否尝试过WriteableBitmap.Invalidate()?
除此之外,您可能想尝试将图像渲染到临时的WriteableBitmap,然后使用WriteableBitmap.Pixels将临时的图像复制到新的位图上。在该新位图上,您应该能够执行图像处理。
干杯,亚历克斯
关于.net - 用颜色覆盖WriteableBitmap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2408376/