Search code examples
c#wpfimageintptr

convert IntPtr to bitmapimage


I use twain_32 for the scan and in twainLib.TransferPictures use DibToBitmap.FormHDib(hbitmap) to get a bitmapsource from IntPtr but I want a bitmapimage.

I want to convert the IntPtr bitmapsource to bitmapimage directly instead to make it a bitmapsource then a bitmapimage


Solution

  • Use the Bitmap Constructor Method

    Bitmap newBitmap = new Bitmap(width, height, Stride, PixelFormat, bitmapSource);