2014-03-14 1 views
0

BitmapImage 개체에 아이콘이로드되어 있는데이 개체를 StdPicture으로 변환해야합니다. 어떻게해야합니까?BitmapImage를 StdPicture로 변환하는 방법

System.Drawing.ImageStdPicture으로 변환하는 방법에 대한 많은 예제가 있지만 System.Windows.Media.Imaging.BitmapImage는 StdPicture이 아닙니다.

먼저 Winforms Image로 변환 한 다음 StdPicture로 변환해야합니까? 나에게 어리석은 소리.

+0

고대 COM 개체이므로 OleCreateIPictureDispIndirect() 도우미 함수는 더 이상 문서화되지 않습니다. BitmapImage와 함께 프로그램에서 사용되는 것을 보는 것은 인간과 공룡의 영화, 시대 착오적 인 영화를 보는 것과 조금 같습니다. BitmapImage를 파일에 저장하는 것은 사실만큼이나 실용적입니다. –

+0

@HansPassant 프로그램 시작시로드 할 이미지가 약 40 개 있습니다. StdPicture 객체를 기대하는 VS 쉘 프로젝트가 있지만 BitmapImage가 있습니다. – fahadash

답변

0

나는 당신이 비트 맵을 의미하는 stdPicture라고 가정하고 있습니다. 그래서 여기에 우리가 간다.

private Bitmap BitmapImageToBitmap(BitmapImage bitmapImage) 
{ 
    using (MemoryStream os = new MemoryStream()) 
    { 
     BitmapEncoder encoder = new BmpBitmapEncoder(); 
     encoder.Frames.Add(BitmapFrame.Create(bitmapImage)); 
     encoder.Save(os); 
     System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(os); 

     return new Bitmap(bitmap); 
    } 
} 
관련 문제