Bitmap으로 실시간 화면 캡쳐 시 화질 저하

실시간 화면 캡쳐 기능을 만들고 있는데 WPF에서 CopyFromScreen을 사용하여 BitmapImage를 이용해 화면 캡처 기능을 만들었는데 실행했을 때 화질 저하가 있습니다. 어떻게 해결할 수 있을까요?
image

 private BitmapImage Capture(System.Drawing.Point mousePoint)
        {
            Bitmap bitmap = new Bitmap(50, 50, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            using (Graphics g = Graphics.FromImage(bitmap))
            {
                int currPosXOnCenter = (int)mousePoint.X - 25;
                int currPosyOnCenter = (int)mousePoint.Y - 25;
                g.CopyFromScreen(currPosXOnCenter <= 0 ? 0 : currPosXOnCenter, currPosyOnCenter <= 0 ? 0 : currPosyOnCenter, 0, 0, bitmap.Size);
                //g.CopyFromScreen(0, 0, 0, 0, bitmap.Size);

                using (MemoryStream memory = new MemoryStream())
                {
                    bitmap.Save(memory, ImageFormat.Bmp);
                    memory.Position = 0;
                    BitmapImage bitmapImage = new BitmapImage();
                    bitmapImage.BeginInit();
                    bitmapImage.StreamSource = memory;
                    bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
                    bitmapImage.EndInit();

                    return bitmapImage;
                }
            }
        }
private void timer_Tick(object sender, EventArgs e)
        {
            this.captureScreen.Source = this.Capture(System.Windows.Forms.Cursor.Position);
        }
 public MainWindow()
        {
            InitializeComponent();
            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromTicks(1000); 
            timer.Tick += new EventHandler(timer_Tick);
            timer.Start();
        }
4개의 좋아요

해결방법을 찾았습니다.

<Image Source=""
       RenderOptions.BitmapScalingMode="NearestNeighbor"
       RenderOptions.EdgeMode="Aliased"/>

이미지 태그에 RenderOption을 추가해주었더니 화질이 개선되었습니다.
image

5개의 좋아요