Overlay WriteableBitmap with color

I am trying to overlay WriteableBitmap with a specific color in Silverlight. I have a black and white base image that I use to create smaller WriteableBitmap images for the new composite image, and I want to overlay either the black or white part of the original image with a specific color before adding it to the composite image.

Now I do the following:

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 http://blogs.silverarcade.com/silverlight-games-101/15/silverlight-blitting-and-blending-with-silverlights-writeablebitmap/ and used the extension methods from hxxp: //writeablebitmapex.codeplex.com/ but I can't seem to get the color overlay on the cutOut image before displaying it in the composite image.

Does anyone know of a good method for doing this?

Thanks in advance.

+3
source share
1 answer

just quick guess, but have you tried playing with WriteableBitmap.Invalidate () after writing WriteableBitmap.Render (...)? Alternatively, you can try to map the image to a temporary WriteableBitmap, and then copy this temporary to a new bitmap using WriteableBitmap.Pixels. On this new bitmap, you can manipulate images.

Greetings, Alex

+1
source

Source: https://habr.com/ru/post/1736089/


All Articles