화면 Capture 앱을 WPF로 만들고 있습니다.
DPI문제에서 막혔습니다.
다음과 같이 범위를 지정해서 찍으면
다음과 같이 찍힙니다.
제 모니터 해상도가 3840 * 2160인데 배율을 200%로 써서 WPF는 논리좌표인 그 1/4인 1920 * 1280으로 작동하는 것 같습니다 해결 방법을 AI도 추천해 줬으나 해당 방법을 적용하여 해결하지 못하였습니다.
해본것은 다음과 같이 manifest를 작성하여 추가 해보았으나 여전합니다.
1. app.manifest에 DPI Awareness 선언
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" processorArchitecture="msil" name="CaptureAgent" type="win32" />
<description>Screen Capture Application</description>
<!-- DPI Awareness 설정 (고해상도 디스플레이 지원) -->
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<!-- Per-Monitor DPI Awareness v2 (권장) -->
<dpiAware>PerMonitorV2,PerMonitor</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
<!-- Windows 호환성 -->
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" /> <!-- Windows 7 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" /> <!-- Windows 8 -->
<supportedOS Id="{1f676c76-80e1-6b23-1b78-7f766f014de6}" /> <!-- Windows 8.1 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" /> <!-- Windows 10/11 -->
This file has been truncated. show original
<!-- app.manifest -->
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
PerMonitorV2
</dpiAwareness>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
True/PM
</dpiAware>
</windowsSettings>
</application>
AI에 여러차례 질문하고 코드에 적용해보았으나 알기 힘들어 실례를 무릅쓰고 질문 드립니다. 바쁘신데 읽어주셔서 감사합니다.
1 Like
이게 맞는지는 잘 모루겠지만…
wpf 의 diu 와 ppi 관련된 내용을 검색해보면
# Per Monitor DPI
Developer Guide
## Introduction
This developer guide provides developer info on how to test your WPF application with our Per Monitor DPI feature released in .NET 4.6.2 along with the Windows 10 Anniversary Update.
## Operating System Prerequisites
In order to enable Per Monitor DPI Awareness in your app, you should be running Windows 10 Anniversary Update or higher.
## Enabling Per Monitor DPI for your app
### 1) Turn on Windows level Per monitor DPI awareness in app.manifest
WPF apps are System DPI aware by default, and need to declare themselves to be Per Monitor DPI aware via an app.manifest file. To add an app.manifest:
- Right click on your project folder, click Add -> New Item
- Click on General in the left pane, and chose Application Manifest File.
- Uncomment the following snippet of xml:
```xml
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
This file has been truncated. show original
요로케 나오긴 하네요.
근본적으로는 지식적인 측면도 필요하겠죵??
정성태님의 글이 제일 공부하기 좋은 거 같네요.
뭔가 ai 한테 물린 사람들 모임이라도 해야하나 싶은 생각도 드는 군요..
(오늘도 저는 ai 의 구라를 판독하느라 시간을 다 씁니다…)
5 Likes
Ivory
June 26, 2026, 12:46pm
4
WPF 는 DP 단위이고 화면 캡쳐는 픽셀단위이기 때문에 DP <=> 픽셀값 변환을 해서 사용하셔야 합니다. DPI Awareness 설정을 해야 하는 이유는 DPI Awareness 설정을 해야 WPF 앱에서 현재 윈도우의 확대 배율을 알 수 있기 때문입니다. 확대 배율을 알면 DP <=> 픽셀값 변환이 가능합니다.
계산이 귀찮으시면 다음 nuget 패키지 사용하시면 됩니다. 편리하죠^^
Porting of Windows Forms Screen helper for Windows Presentation Foundation (WPF). It avoids dependencies on Windows Forms libraries when developing in WPF.
4 Likes
감사합니다 Merge 했습니다.
영역 지정 할 때 dpi적용 안되던 문제는 불편하지만 그냥 써야겠다고 생각 했었는데 이 부분도 해결 해주셔서 감사드립니다.
3 Likes
알려주신 링크의 글 잘 봤습니다. 역시 펫졸드의 글을 인용 했네요.
제가 이 캡춰 앱을 만든 이유가 fliphtml5.com/lciv/ypxy 펫졸드의 WPF책이 절판이 되어 이 사이트에서 밖에 볼 수가 없는데 보기가 불편해서 찍어서 OCR해서 코드만 추출 하려고 만들었던 것이었습니다.
1 Like