Reputation: 469
UPDATE: Is not a duplicate.
My question is not how to take a screenshot. I know this, but it's not what I need. I can have others controls over the Canvas and I don't want to capture them but just the image in the Canvas with the image that is visible in transparency under the Canvas.
I need to capture the image on a Canvas with opacity 50% but the image captured have a black background instead of the image in background (Desktop).
I use this code to capture the image:
MemoryStream ms = new MemoryStream();
RenderTargetBitmap rtb = new RenderTargetBitmap(1920, 1080, 96d, 96d, PixelFormats.Default);
rtb.Render(canvasCapture);
BmpBitmapEncoder BmpEncoder = new BmpBitmapEncoder();
BmpEncoder.Frames.Add(BitmapFrame.Create(rtb));
BmpEncoder.Save(ms);
This is the Canvas:
<Canvas x:Name="canvasCapture" Background="#7F0F0F0E" />
On my application I can see the Desktop in transparency under the Canvas but the captured image have a black background. How Can I capture the image with the background as I see it in the application?
Upvotes: -1
Views: 882
Reputation: 1
Bitmap images don't support transparent backgrounds. It automatically fills transparent areas with black. You may try to save and use your images as PNG.
Upvotes: 0