Hi… Finally I’m able to fill N18 display with RGB color 64x40 boxes (not 2 byte as mentioned before) and without “Out of memory”… Maybe following code will be helpful to someone. BTW: Anyone knows what is the 4th byte for? I’ve expected 3 bytes…
namespace GadgeteerApp1
{
public partial class Program
{
byte[] data;
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{
display_N18.Initialize(4000);
display_N18.EnableBacklight(true);
DrawMyBitmap(000, 000, 255, 64, 40);
display_N18.DrawBitmapRawData(data, 00, 00, 64, 40);
DrawMyBitmap(000, 255, 000, 64, 40);
display_N18.DrawBitmapRawData(data, 64, 00, 64, 40);
DrawMyBitmap(000, 255, 255, 64, 40);
display_N18.DrawBitmapRawData(data, 00, 40, 64, 40);
DrawMyBitmap(255, 000, 000, 64, 40);
display_N18.DrawBitmapRawData(data, 64, 40, 64, 40);
DrawMyBitmap(255, 000, 255, 64, 40);
display_N18.DrawBitmapRawData(data, 00, 80, 64, 40);
DrawMyBitmap(255, 255, 000, 64, 40);
display_N18.DrawBitmapRawData(data, 64, 80, 64, 40);
DrawMyBitmap(255, 255, 255, 64, 40);
display_N18.DrawBitmapRawData(data, 00, 120, 64, 40);
DrawMyBitmap(128, 128, 128, 64, 40);
display_N18.DrawBitmapRawData(data, 64, 120, 64, 40);
}
public void DrawMyBitmap(byte R, byte G, byte B, int Width, int Height)
{
if (data==null) {
data = new byte[Width * Height * 4];
}
uint index;
int row;
int col;
for (row = 0; row < Height; row++)
{
for (col = 0; col < Width; col++)
{
//Fill partial bitmap
index = (uint)(row * Width * 4 + col * 4);
if (index < Width * Height * 4)
{
data[index + 0] = R;
data[index + 1] = G;
data[index + 2] = B;
data[index + 3] = 0xFF;
}
else
{
Debug.Print("Array index overflow at data[" + index.ToString() + "]");
}
}
}
}
}
}