Skip to content

[优化]-截图功能图片精度调整 #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/WPFDevelopers.Shared/Controls/ScreenCut/ScreenCut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,19 @@ private CroppedBitmap CutBitmap()
_rectangleTop.Visibility = Visibility.Collapsed;
_rectangleRight.Visibility = Visibility.Collapsed;
_rectangleBottom.Visibility = Visibility.Collapsed;
var renderTargetBitmap = new RenderTargetBitmap((int)_canvas.Width,
(int)_canvas.Height, 96d, 96d, PixelFormats.Default);
// 屏幕等比截图需要考虑缩放率进行等比放大canvas
var renderTargetBitmap = new RenderTargetBitmap((int)(_canvas.Width * screenDPI.scaleX),
(int)(_canvas.Height * screenDPI.scaleY), screenDPI.dpiX, screenDPI.dpiY, PixelFormats.Default);
renderTargetBitmap.Render(_canvas);
return new CroppedBitmap(renderTargetBitmap,
new Int32Rect((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height));
// 屏幕等比截图需要考虑缩放率进行等比放大截图区域
var realrect = new Int32Rect(
(int)(rect.X * screenDPI.scaleX),
(int)(rect.Y * screenDPI.scaleY),
(int)(rect.Width * screenDPI.scaleX),
(int)(rect.Height * screenDPI.scaleY));
//return new CroppedBitmap(renderTargetBitmap,
// new Int32Rect((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height));
return new CroppedBitmap(renderTargetBitmap, realrect);
}

private void ButtonCancel_Click(object sender, RoutedEventArgs e)
Expand Down