Reputation: 399
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?
Upvotes: 3
Views: 1539
Reputation: 6698
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.
Upvotes: 4
Reputation: 25516
You can convert an Image
to a Bitmap
with
System.Drawing.Bitmap(loadedimage)
Upvotes: 2