I get
System.ArgumentException: 'Parameter is not valid.'
for some reason.
The line in which I get:
let image = Bitmap.FromStream stream
What i have
let ChangeBitmapColors (bitmap : Bitmap) =
Console.WriteLine bitmap.Size
let width = bitmap.Width
let height = bitmap.Height
let rectangle = new Rectangle(0, 0, width, height)
let bitmapData = bitmap.LockBits(rectangle, Imaging.ImageLockMode.ReadOnly, bitmap.PixelFormat)
let length = bitmapData.Stride * height
let bitmapArray : byte[] = Array.zeroCreate length
Marshal.Copy(bitmapData.Scan0, bitmapArray, 0, length)
bitmap.UnlockBits bitmapData
use stream = new MemoryStream(bitmapArray)
let image = Bitmap.FromStream stream
stream.Dispose |> ignore
image
Any ideas what I'm doing wrong here? Thanks in advance.
source
share