私は2つのコントロール画像ビューとキャンバスを持っています。 イメージの上に私は矩形を描画しています。スクリーンショットを撮っている間、私は矩形ではなくイメージを取得しています。コードの下に使用WPFのScreenShot
iは
int Width = (int)canvas1.RenderSize.Width;
int Height = (int)canvas1.RenderSize.Height;
RenderTargetBitmap renderTargetBitmap =
new RenderTargetBitmap(Width, Height, 96, 96, PixelFormats.Pbgra32);
renderTargetBitmap.Render(canvas1);
PngBitmapEncoder pngImage = new PngBitmapEncoder();
pngImage.Frames.Add(BitmapFrame.Create(renderTargetBitmap));
using (Stream fileStream = File.Create(filePath))
{
pngImage.Save(fileStream);
}
私はイメージ画像のみでキャンバスを交換していた場合には来ている黒画像を取得しています。 両方のコントロールを含むスクリーンショットを撮るには?
画像にキャンバス、キャンバス、画像に長方形をハードコードしました。あなたのコードは、Button.Clickの中で私のためにうまくいきます。 – AnjumSKhan
はスクリーンショットを撮ることができますか? –
矩形で画像を保存できます。 – AnjumSKhan