Converting a Bitmap image to a matrix

bitmap, c#, matrix

Solution

Try something like this:

public Color[][] GetBitMapColorMatrix(string bitmapFilePath)
{
    bitmapFilePath = @"C:\9673780.jpg";
    Bitmap b1 = new Bitmap(bitmapFilePath);

    int hight = b1.Height;
    int width = b1.Width;

    Color[][] colorMatrix = new Color[width][];
    for (int i = 0; i < width; i++)
    {
        colorMatrix[i] = new Color[hight];
        for (int j = 0; j < hight; j++)
        {
            colorMatrix[i][j] = b1.GetPixel(i, j);
        }
    }
    return colorMatrix;
}

Problem

In C#, I need to convert an image that I have already converted to Bitmap in to a matrix of the size of the image's width and height that consists of the uint8 of the Bitmap data. In another word placing the Bitmap data inside of a matrix and converting them to uint8, so I can do the calculations that I am intended to do on the matrix rows and column.

Original source