Name: Anonymous 2013-11-24 14:20
hey
ive got a problem with some c# code. ive got a panel and im drawing a game map, save it in a bitmap and make the bitmap the backgroundimage of my panel. so far, so fine. but i want to highlighte the field (there are several fields in the map) on which my mouse is over. but if i change the colour of the field and draw it again, and set the image again as the background, the map is flickering. especially if i move quickly around 2 fields, so the colour is often changed and the resetting of the image happens to often. i havnt any clue what to do, to solve the problem.
any idea how i could draw the map without flickering? would appreciate it.
my drawmap method
z_asBitmap = new Bitmap(pnlMap.Width, pnlMap.Height);
z = Graphics.FromImage(z_asBitmap);
for (int i = 0; i < Game.numberOfFields; ++i)
{
Point[] tempPoints = Game.GiveFieldToDraw(i).corners;
Point[] realPoints = new Point[Game.GiveFieldToDraw(i).corners.Length];
for (int j = 0; j < realPoints.Length; ++j)
{
realPoints[j].X = (tempPoints[j].X * Factor);
realPoints[j].Y = (tempPoints[j].Y * Factor);
}
SolidBrush tempObjectbrush = new SolidBrush(Game.GiveFieldToDraw(i).colorOfField);
z.FillPolygon(tempObjectbrush, realPoints);
z.DrawPolygon(stift, realPoints);
}
pnlMap.BackgroundImage = z_asBitmap;
ive got a problem with some c# code. ive got a panel and im drawing a game map, save it in a bitmap and make the bitmap the backgroundimage of my panel. so far, so fine. but i want to highlighte the field (there are several fields in the map) on which my mouse is over. but if i change the colour of the field and draw it again, and set the image again as the background, the map is flickering. especially if i move quickly around 2 fields, so the colour is often changed and the resetting of the image happens to often. i havnt any clue what to do, to solve the problem.
any idea how i could draw the map without flickering? would appreciate it.
my drawmap method
z_asBitmap = new Bitmap(pnlMap.Width, pnlMap.Height);
z = Graphics.FromImage(z_asBitmap);
for (int i = 0; i < Game.numberOfFields; ++i)
{
Point[] tempPoints = Game.GiveFieldToDraw(i).corners;
Point[] realPoints = new Point[Game.GiveFieldToDraw(i).corners.Length];
for (int j = 0; j < realPoints.Length; ++j)
{
realPoints[j].X = (tempPoints[j].X * Factor);
realPoints[j].Y = (tempPoints[j].Y * Factor);
}
SolidBrush tempObjectbrush = new SolidBrush(Game.GiveFieldToDraw(i).colorOfField);
z.FillPolygon(tempObjectbrush, realPoints);
z.DrawPolygon(stift, realPoints);
}
pnlMap.BackgroundImage = z_asBitmap;