开发者

How to convert ImageSource to bitmap?

开发者 https://www.devze.com 2023-01-31 13:30 出处:网络
I need to convert ImageSource to simple Bitmap ( System.Drawing.Bitmap ) How can i do i开发者_运维技巧t ?

I need to convert ImageSource to simple Bitmap ( System.Drawing.Bitmap )

How can i do i开发者_运维技巧t ?

Thanks


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

精彩评论

暂无评论...
验证码 换一张
取 消