Click to See Complete Forum and Search --> : Setting the Background of an Graphics [C#]


Shaitan00
July 13th, 2006, 08:24 PM
Given the following code:

Bitmap img = new Bitmap(nLevelWidth, nLevelHeight);
Graphics gLevel = Graphics.FromImage(img);

Bitmap imgBelow = _imgIcon;
imgBelow.MakeTransparent();
gLevel.DrawImage(imgBelow, i, j, SIZE, CELL_SIZE);

// NOW I NEED TO SET THE BACKCOLOR OF THE GRAPHICS BEFORE I PUT IT ON THE SCREEN


So, I create a new Image (img) and load its Graphics (gLevel) so I can draw on it, then I draw an Icon somewhere on it (can be anywhere, and can be any kind of Icon)...
After that is done I need to give my Image (img) a BACKCOLOR / BACKGROUND and oddly enough I can't seem to figure out how to set that property...

Any ideas, hints, and help would be greatly appreciated, thanks

Norfy
July 14th, 2006, 03:16 AM
You have to fill the background bitmap before you draw the icon on it.

Bitmap img = new Bitmap(nLevelWidth, nLevelHeight);
Graphics gLevel = Graphics.FromImage(img);
gLevel.FillRectangle(...);
Bitmap imgBelow = _imgIcon;
imgBelow.MakeTransparent();
gLevel.DrawImage(imgBelow, i, j, SIZE, CELL_SIZE);