■ RenderTargetBitmap 클래스 사용하기

----------------------------------------------------------------------------------------------------


TestProject.zip


MainWindow.cs

 

 

using System;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Media;

using System.Windows.Media.Imaging;

 

namespace TestProject

{

    /// <summary>

    /// 메인 비트맵

    /// </summary>

    public class MainWindow : Window

    {

        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor

        ////////////////////////////////////////////////////////////////////////////////////////// Public

 

        #region 생성자 - MainWindow()

 

        /// <summary>

        /// 생성자

        /// </summary>

        public MainWindow()

        {

            Width      = 800;

            Height     = 600;

            Title      = "RenderTargetBitmap 클래스 사용하기";

            FontFamily = new FontFamily("나눔고딕코딩");

            FontSize   = 16;

 

            Background = Brushes.White;

 

            RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(300, 300, 96, 96, PixelFormats.Default);

 

            DrawingVisual drawingVisual = new DrawingVisual();

 

            DrawingContext drawingContext = drawingVisual.RenderOpen();

 

            drawingContext.DrawRoundedRectangle(Brushes.Blue, new Pen(Brushes.Red, 10), new Rect(25, 25, 250, 250), 10, 10);

 

            drawingContext.Close();

 

            renderTargetBitmap.Render(drawingVisual);

 

            Image image = new Image();

 

            image.Source  = renderTargetBitmap;

            image.Stretch = Stretch.None;

 

            Content = image;

        }

 

        #endregion

 

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method

        ////////////////////////////////////////////////////////////////////////////////////////// Static

        //////////////////////////////////////////////////////////////////////////////// Public

 

        #region 프로그램 시작하기 - Main()

 

        /// <summary>

        /// 프로그램 시작하기

        /// </summary>

        [STAThread]

        public static void Main()

        {

            Application application = new Application();

 

            application.Run(new MainWindow());

        }

 

        #endregion

    }

}

 

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker

댓글을 달아 주세요