Overlay WriteableBitmap with color
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.
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
链接地址: http://www.djcxy.com/p/26870.html上一篇: Wpf:为什么WriteableBitmap变慢?
下一篇: 用颜色覆盖WriteableBitmap