Preza8
Preza8

Reputation: 399

Loading .png to Bitmap

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

Answers (2)

John Willemse
John Willemse

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

John Palmer
John Palmer

Reputation: 25516

You can convert an Image to a Bitmap with

System.Drawing.Bitmap(loadedimage)

Upvotes: 2

Related Questions