Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

As far as I'm aware there is no simple way to change the background in the manner you describe, because quite simply there is no such thing as a background. To the best of my knowledge the bitmap object is single layer meaning that it has no way of distinguishing a difference between what you think is the background and the image. One way of doing this would be to research some of the various flood fill options, but that could potentially become complicated.

 

The simplest approach would be to set the background colour before drawing the imagine by calling gLevel.Clear(backCol);

Anybody looking for a graduate programmer (Midlands, England)?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...