I need to access pixels of a .png file through F#.
I can load it into an Image by its FromFile method, but I can't access its pixels. I don't know how to turn an Image into a Bitmap. Where I could use a GetPixel method?
You can load the image directly into a Bitmap object:
let img = "C:\\MyImages\\MyImage.png"
let bitmap = new System.Drawing.Bitmap(img)
From there on you can use the methods and properties of Bitmap on the image.
You can convert an Image to a Bitmap with
System.Drawing.Bitmap(loadedimage)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With