728x90
반응형
728x170
■ BitmapSource 클래스를 사용해 WINFORM Bitmap 객체에서 비트맵 소스를 구하는 방법을 보여준다.
▶ 예제 코드 (C#)
using System;
using System.Drawing;
using System.Windows.Interop;
using System.Windows.Media.Imaging;
#region 비트맵 소스 구하기 - GetBitmapSource(bitmap)
/// <summary>
/// 비트맵 소스 구하기
/// </summary>
/// <param name="bitmap">WINFORM 비트맵</param>
/// <returns>비트맵 소스</returns>
public BitmapSource GetBitmapSource(Bitmap bitmap)
{
IntPtr bitmapHandle = bitmap.GetHbitmap();
BitmapSource bitmapSource = Imaging.CreateBitmapSourceFromHBitmap
(
bitmapHandle,
IntPtr.Zero,
Int32Rect.Empty,
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions()
);
return bitmapSource;
}
#endregion
728x90
반응형
그리드형(광고전용)
'C# > WPF' 카테고리의 다른 글
[C#/WPF] Dispatcher 클래스 : Invoke 메소드를 사용해 크로스 스레드(Cross Thread) 처리하기 (0) | 2014.02.21 |
---|---|
[C#/WPF] ASCII ART 문자열 구하기 (0) | 2014.02.21 |
[C#/WPF] SolidColorBrush 클래스 : 디폴트 시스템 색상 오버라이딩 하기 (0) | 2014.02.20 |
[C#/WPF] Ellipse 엘리먼트 : 커졌다 사라지는 동심원 애니메이션 설정하기 (0) | 2014.02.20 |
[C#/WPF] BitmapSource 클래스 : WINFORM Icon 객체에서 비트맵 소스 구하기 (0) | 2014.02.20 |
[C#/WPF] ListBox 엘리먼트 : ItemContainerStyle 속성을 사용해 선택한 Icon 항목을 크게 만드는 애니메이션 설정하기 (0) | 2014.02.20 |
[C#/WPF] ListBox 엘리먼트 : ItemContainerStyle 속성을 사용해 항목 크기 애니메이션 설정하기 (0) | 2014.02.20 |
[C#/WPF] ControlTemplate 엘리먼트 : Button 엘리먼트 정의하기 (0) | 2014.02.20 |
[C#/WPF] ComboBox 엘리먼트 : 폰트 ComboBox 설정하기 (0) | 2014.02.20 |
[C#/WPF] Window 클래스 : 전체 화면 크기 설정하기 (0) | 2014.02.20 |
댓글을 달아 주세요