i'm just doing a simple job: Converting a bitmap into an array, then using that array, recreating the bitmap with BitmapSource.Create method.
However, i'm getting the error: "Value does not fall within the expected range". Here's my code.
Dim width As Integer = bitmapImage.PixelWidth
Dim height As Integer = bitmapImage.PixelHeight
Dim bytesPerPixel As Integer = bitmapImage.Format.BitsPerPixel / 8
Dim stride As Integer = width * bytesPerPixel
Dim pixelBuffer = New Byte(height * stride - 1) {}
bitmapImage.CopyPixels(pixelBuffer, stride, 0)
Dim bmpSource As BitmapSource = BitmapSource.Create(width, height, 96, 96, PixelFormats.Bgr32, Nothing, pixelBuffer, width)
Image2.Source = bmpSource
Any help regarding that will be appreciated, thank you.