Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading .png to Bitmap

Tags:

bitmap

png

f#

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?

like image 819
Preza8 Avatar asked Dec 06 '25 17:12

Preza8


2 Answers

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.

like image 139
John Willemse Avatar answered Dec 09 '25 00:12

John Willemse


You can convert an Image to a Bitmap with

System.Drawing.Bitmap(loadedimage)
like image 28
John Palmer Avatar answered Dec 08 '25 23:12

John Palmer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!