C# 윈폼 이미지를 WPF 이미지로 변환하기. (Converting WinForms Image to WPF Image.)
페이지 정보
본문
윈폼 이미지를 WPF 이미지로 변환하는 메소드입니다.
/// <summary>
/// 이미지를 WPF 이미지로 변환합니다.
/// </summary>
/// <param name="image"><see cref="System.Drawing.Image" /></param>
/// <returns><see cref="System.Windows.Media.Imaging.BitmapImage" /></returns>
public static BitmapImage ToWpfBitmapImage(System.Drawing.Image image)
{
if (image == null)
return null;
var bimg = new BitmapImage();
var ms = new MemoryStream();
image.Save(ms, ImageFormat.Png);
ms.Seek(0, SeekOrigin.Begin);
bimg.BeginInit();
bimg.StreamSource = ms;
bimg.EndInit();
return bimg;
}
개발자에게 후원하기
추천, 구독, 홍보 꼭~ 부탁드립니다.
여러분의 후원이 빠른 귀농을 가능하게 해줍니다~ 답답한 도시를 벗어나 귀농하고 싶은 개발자~
감사합니다~
추천1 비추천0
- 이전글최상위 매인폼을 가져오는 방법. (How to get the top-level main form.) 21.06.09
- 다음글C# 시작 위치와 끝 위치를 연결하는 라인 그리기. (Draw a line connecting the start and end positions.) 21.06.07
댓글목록
등록된 댓글이 없습니다.