0
WPF 응용 프로그램이 있습니다. 응용 프로그램에는 2 개의 웹 페이지가 내장되어 있습니다. 스크린 샷을 찍을 때 포함 된 웹 페이지를 제외하고는 전체 응용 프로그램을 얻습니다.WPF 사용 방법 웹 페이지가 포함 된 스크린 샷
웹 페이지를 포함한 스크린 샷을 찍어야합니다. 누군가가
감사합니다 ..
WPF 응용 프로그램이 있습니다. 응용 프로그램에는 2 개의 웹 페이지가 내장되어 있습니다. 스크린 샷을 찍을 때 포함 된 웹 페이지를 제외하고는 전체 응용 프로그램을 얻습니다.WPF 사용 방법 웹 페이지가 포함 된 스크린 샷
웹 페이지를 포함한 스크린 샷을 찍어야합니다. 누군가가
감사합니다 ..
try
{
// System.Drawing.Point p=new System.Drawing.Point(100,500);
Bitmap b = new Bitmap(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
Graphics graphics=Graphics.FromImage(b as Image);
graphics.CopyFromScreen(0,0,0,0,b.Size);
string [email protected]"C:\Image1";
b.Save(stringsFile,ImageFormat.Png);
}
catch (Exception exp)
{
Microsoft.Windows.Controls.MessageBox.Show("Opps !!! " + exp.Message);
}
날 안내 주실 래요 당신이 코드
/// Gets a JPG "screenshot" of the current UIElement
///
/// UIElement to screenshot
/// Scale to render the screenshot
/// JPG Quality
/// Byte array of JPG data
public static byte[] GetJpgImage(this UIElement source, double scale, int quality)
{
double actualHeight = source.RenderSize.Height;
double actualWidth = source.RenderSize.Width;
double renderHeight = actualHeight * scale;
double renderWidth = actualWidth * scale;
RenderTargetBitmap renderTarget = new RenderTargetBitmap((int) renderWidth, (int) renderHeight, 96, 96, PixelFormats.Pbgra32);
VisualBrush sourceBrush = new VisualBrush(source);
DrawingVisual drawingVisual = new DrawingVisual();
DrawingContext drawingContext = drawingVisual.RenderOpen();
using (drawingContext)
{
drawingContext.PushTransform(new ScaleTransform(scale, scale));
drawingContext.DrawRectangle(sourceBrush, null, new Rect(new Point(0, 0), new Point(actualWidth, actualHeight)));
}
renderTarget.Render(drawingVisual);
JpegBitmapEncoder jpgEncoder = new JpegBitmapEncoder();
jpgEncoder.QualityLevel = quality;
jpgEncoder.Frames.Add(BitmapFrame.Create(renderTarget));
Byte[] _imageArray;
using (MemoryStream outputStream = new MemoryStream())
{
jpgEncoder.Save(outputStream);
_imageArray = outputStream.ToArray();
}
return _imageArray;
}
이 작동하지 않는, 화면의 웹 페이지 부분이 빈 온다 시도 할 수 있습니다. – Vinay