private static void DrawMatrix(BrickletOLED64x48 oled, bool[][] pixels) { byte[][] pages = new byte[HEIGHT / 8][]; for (int row = 0; row < HEIGHT / 8; row++) { pages[row] = new byte[WIDTH]; for (int column = 0; column < WIDTH; column++) { pages[row][column] = 0; for (int bit = 0; bit < 8; bit++) { if (pixels[(row * 8) + bit][column]) { pages[row][column] |= (byte)(1 << bit); } } } } oled.NewWindow(0, (byte)(WIDTH - 1), 0, (byte)(HEIGHT / 8 - 1)); for (int row = 0; row < HEIGHT / 8; row++) { oled.Write(pages[row]); } }
private static void DrawBitmap(BrickletOLED64x48 oled, Bitmap bitmap) { byte[][] pages = new byte[HEIGHT / 8][]; for (int row = 0; row < HEIGHT / 8; row++) { pages[row] = new byte[WIDTH]; for (int column = 0; column < WIDTH; column++) { pages[row][column] = 0; for (int bit = 0; bit < 8; bit++) { if (bitmap.GetPixel(column, (row * 8) + bit).GetBrightness() > 0) { pages[row][column] |= (byte)(1 << bit); } } } } oled.NewWindow(0, (byte)(WIDTH - 1), 0, (byte)(HEIGHT / 8 - 1)); for (int row = 0; row < HEIGHT / 8; row++) { oled.Write(pages[row]); } }