2010-12-22 4 views
1

ImageSource를 간단한 비트 맵 (System.Drawing.Bitmap)으로 변환해야합니다.ImageSource를 비트 맵으로 변환하는 방법?

어떻게해야합니까?

감사

+0

가능한 복제본 [Convert System.Windows.Media.ImageSource to System.Drawing.Bitmap] (http://stackoverflow.com/questions/1201518/convert-system-windows-media-imagesource-to-system-drawing) 비트 맵) –

답변

4
 Public Function WpfBitmapSourceToBitmap(ByVal source As BitmapSource) As System.Drawing.Bitmap 
      Dim bmp As New System.Drawing.Bitmap(source.PixelWidth, source.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb) 
      Dim data As System.Drawing.Imaging.BitmapData = bmp.LockBits(New System.Drawing.Rectangle(System.Drawing.Point.Empty, bmp.Size), System.Drawing.Imaging.ImageLockMode.[WriteOnly], System.Drawing.Imaging.PixelFormat.Format32bppPArgb) 
      source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride) 
      bmp.UnlockBits(data) 
      Return bmp 
     End Function 

이 도움이 될 것입니다 경우 답변으로 표시하십시오!

+0

좋아요! 그것은 작동합니다! –

관련 문제