How to load a raster file in a .NET console application

I'm trying to create a C # console application that starts by loading an 8-bit level bitmap file (usually BMP) and converting it into an array of two-dimensional bytes, where (as you would expect) the byte in position x, y is the pixel intensity x, y. Then I have a lot of code that will work on the raster array as an array.

The problem is that I saw how this is done with calls from WPF modules that are simply not available in the console application. I do not want to use System.Windows.Media.Imaging, for example.

Does anyone have any suggestions on how I can do this without much trouble?

+3
source share
2 answers

System.Drawing.dll . System.Drawing.Bitmap.

, System.Drawing:

using System.Drawing;

:

Bitmap bitmap = (Bitmap)Image.FromFile(@"mypath.bmp");

:

bitmap.Dispose();

, :

int width = bitmap.Width;
int height = bitmap.Height;
Color pixel00 = bitmap.GetPixel(0, 0);
+6

System.Drawing.Bitmap ctor, .

0

All Articles