Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

C# flickering panel

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;

Name: Anonymous 2013-11-24 14:27

Hey.
I've got a problem reading your illiterate garbled nonsense. Try learning English before making any more posts.

Name: Anonymous 2013-11-24 14:42

sorry... im not a native speaker... i try it again.
I'm trying to make a game with c#. There should be a Map within a panel. There are different fields in the map. The Map is drawn in a bitmap and this bitmap is the "backgroundimage" of the Panel. That works all fine. But i would like, that, if i move the mouse over the map and the different fields, the colour of the field under my mouse changes. For that i have to draw the map again, with the changed colour of the field, which is under my mouse. After that i have to set the nem bitmap as the "backgroundimage". The Problem is, that the map is flickering, because the "backgroundimage" is changed that often, if i go over the whole map quickly. Then the colours have to change often.
I hope you could understand it know.
Would appreciate if you could help me.

Don't change these.
Name: Email:
Entire Thread Thread List