728x90
728x170
■ RenderTargetBitmap 클래스를 사용해 Image 객체에서 비트맵을 구하는 방법을 보여준다.
▶ 예제 코드 (C#)
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
#region 비트맵 구하기 - GetBitmap(image)
/// <summary>
/// 비트맵 구하기
/// </summary>
/// <param name="image">이미지</param>
/// <returns>렌더 타겟 비트맵</returns>
public RenderTargetBitmap GetBitmap(Image image)
{
RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap
(
(int)image.ActualWidth,
(int)image.ActualHeight,
96.0,
96.0,
PixelFormats.Pbgra32
);
image.Measure(new Size((int)image.ActualWidth, (int)image.ActualHeight));
image.Arrange(new Rect(new Size((int)image.ActualWidth, (int)image.ActualHeight)));
renderTargetBitmap.Render(image);
return renderTargetBitmap;
}
#endregion
※ Image 객체가 메모리에 로드된 다음 상기 함수를 사용해야 한다.
728x90
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] FlowDocument 클래스 : RTF 파일 로드하기 (0) | 2021.02.15 |
---|---|
[C#/WPF] FlowDocument 클래스 : RTF 파일을 XAML로 변환하기 (0) | 2021.02.15 |
[C#/WPF] DependencyProperty 클래스 : OverrideMetadata 메소드를 사용해 표준 의존 속성 디폴트 값 설정하기 (0) | 2021.02.14 |
[C#/WPF] Shape 클래스 : 커스텀 파일 슬라이스(Pie Slice) 사용하기 (0) | 2021.02.14 |
[C#/WPF] BitmapSource 클래스 : WINFORM Bitmap 객체 구하기 (0) | 2021.02.14 |
[C#/WPF] 페이지 전환 애니메이션 사용하기 (0) | 2021.02.14 |
[C#/WPF] 페이지 전환 애니메이션 사용하기 (0) | 2021.02.14 |
[C#/WPF] MultiSelector 클래스 : 선택/이동/크기 변경 가능한 캔버스 사용하기 (0) | 2021.02.13 |
[C#/WPF] Canvas 클래스 : 자식 엘리먼트 드래그하기 (0) | 2021.02.13 |
[C#/WPF] ListBox 클래스 : 확장 가능한 리스트 박스 사용하기 (0) | 2021.02.12 |