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
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] Label 엘리먼트 : Target 속성 사용하기 (0) | 2014.01.31 |
---|---|
[C#/WPF] CroppedBitmap 클래스 : 비트맵 소스에서 비트맵 잘라내기 (0) | 2014.01.31 |
[C#/WPF] CroppedBitmap 엘리먼트 : SourceRect 속성 사용하기 (0) | 2014.01.31 |
[C#/WPF] FormatConvertedBitmap 클래스 : 비트맵 소스 픽셀 포맷 변경하기 (0) | 2014.01.31 |
[C#/WPF] FormatConvertedBitmap 엘리먼트 : DestinationFormat 속성을 사용해 비트맵 픽셀 포맷 변경하기 (0) | 2014.01.31 |
[C#/WPF] BitmapImage 엘리먼트 : DecodePixelWidth/DecodePixelHeight 속성 사용하기 (0) | 2014.01.31 |
[C#/WPF] Image 엘리먼트 : Width 속성 사용하기 (0) | 2014.01.31 |
[C#/WPF] Storyboard 클래스 : 코드 구현하기 (0) | 2014.01.31 |
[C#/WPF] ControlTemplate 엘리먼트 : RelativeSource 태그 확장에서 TemplatedParent 모드 사용하기 (0) | 2014.01.31 |
[C#/WPF] WPF 버전 번호가 저장된 레지스트리 키 (0) | 2014.01.30 |
댓글을 달아 주세요