I am trying to convert some Java code into C# for an application. I can't seem to find the exact equivalent of setPixels method in android.Graphics.Bitmap in C# .NET.
Here is the Java code:
BitMatrix result = some code .....
int w = result.getWidth();
int h = result.getHeight();
int[] pixels = new int[w * h];
for (int y = 0; y < h; y++) {
int offset = y * w;
for (int x = 0; x < w; x++) {
pixels[offset + x] = result.get(x, y) ? BLACK : WHITE;
}
}
Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
bitmap.setPixels(pixels, 0, 480, 0, 0, w, h);
Here is my attempt at converting it into C#:
int w = result.Width;
int h = result.Height;
int[] pixels = new int[w * h];
for (int y = 0; y < h; y++)
{
int offset = y * w;
for (int x = 0; x < w; x++)
{
pixels[offset + x] = result[x, y] ? Color.Black.ToArgb() : Color.White.ToArgb();
}
}
Bitmap bitmap = new Bitmap(w, h);
// how to convert the line below
bitmap.setPixels(pixels, 0, 480, 0, 0, w, h);
How should I go about converting the last line into C#. Any suggestions?