Main Site Documentation

Setting the background color of a bitmap?


Guys, I am using an N18 display with a Hydra to display simple test output. It is working OK. I want to redraw a text line in a given place to update Temperature values (for example).

So, I need to create a small bitmap, set the background color, and draw text on it. Here is the code I have (and it works OK), but is there a better/easier way? I don’t even get what the Gradient parameters are doing in the DrawRectangle call.

     Bitmap bmp = new Bitmap(128, 20);
     bmp.DrawRectangle(Color.White, 10, 0, 0, 128, 20, 2, 2, Color.White, 0, 0, Color.White, 128, 20, 100);
     bmp.DrawText(t.ToString("F") + "° / " + rh.ToString("F0") + "% RH", myLargeFont, GT.Color.Red, 4, 0);
     display_N18.Draw(bmp, 0, 36);

Basically, I draw a 20 pixel high rectangle with a 10 pixel white border and then draw my text on top. Anybody have suggestions for a cleaner way to do this?


@ Blue Hair Bob - MF does not have a fill rectangle method :frowning:

I don’t believe there is a more efficient alternative.


If you’re using a Cerberus family device you might like @ Taylorza’s code in