첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

■ BitmapImage 클래스를 사용해 크기 조정 비트맵 이미지를 구하는 방법을 보여준다.

 

▶ BitmapImage 클래스 : 크기 조정 비트맵 이미지 구하기 예제 (C#)

BitmapImage bitmapImage = GetBitmapImage(new Uri("c:\\pinkcherries.jpg"), 200, null);

 

▶ BitmapImage 클래스 : 크기 조정 비트맵 이미지 구하기 (C#)

using System;
using System.Windows;
using System.Windows.Media.Imaging;

#region 크기 조정 비트맵 이미지 구하기 - GetBitmapImage(uri, pixelWidth, pixelHeight)

/// <summary>
/// 크기 조정 비트맵 이미지 구하기
/// </summary>
/// <param name="uri">URI</param>
/// <param name="pixelWidth">픽셀 너비</param>
/// <param name="pixelHeight">픽셀 높이</param>
/// <returns>크기 조정 비트맵 이미지</returns>
public BitmapImage GetBitmapImage(Uri uri, int? pixelWidth, int? pixelHeight)
{
    BitmapImage bitmapImage = new BitmapImage();

    bitmapImage.BeginInit();

    bitmapImage.UriSource = uri;

    if(pixelWidth.HasValue)
    {
        bitmapImage.DecodePixelWidth = pixelWidth.Value;
    }

    if(pixelHeight.HasValue)
    {
        bitmapImage.DecodePixelHeight = pixelHeight.Value;
    }

    bitmapImage.EndInit();

    return bitmapImage;
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요