Some drawing problems...

S

Senne Vaeyens

Hi,

I'm writing an app that will show a scrolling transparent graph and I'm
ancountering some problems, explained in the following code:
(a VS project explaining the problem(s) can be downloaded at
http://www.icat.be/problems.zip )

The code is executed on a timer.tick event:

// Draw Using Double Buffering, this works perfectly if the monitor
// is set to 16-bit Color mode, if it is set to 32-bit color mode
// the background of the graph will be blue, I know this is a known bug
// bug ID KB820640, will Microsoft resolve this ????
BackgroundBmp.MakeTransparent(Color.Red);

this.OffScreenBmp = new Bitmap(BackgroundBmp);

this.OffScreenDC = Graphics.FromImage(this.OffScreenBmp);

Graphics ClientDC = this.CreateGraphics();

BackGroundBrush = new SolidBrush(Color.Blue); //Blue is the tranparencykey
of the form

this.OffScreenDC.FillRectangle(BackGroundBrush,0,0,this.NumberOfLines,MaxVal
);


for(int i=0;i<CounterArray.Count;i++)

{

Pen myPen = new Pen(Color.Red,1);

//Draw all the vertical Lines

this.OffScreenDC.DrawLine(myPen,i,MaxVal,i,MaxVal - (int)CounterArray);

}


//Put it on the screen

ClientDC.DrawImage(this.OffScreenBmp,0,0);



// Draw using the Region property of Panel1, works perfectly on first sighth

// but when you place this app behind another window, and bring it back to
the

// front, the graph looks kinda "garbled", I don't know why, can someone
explain this?

// Is this a bug ???


myPath = new GraphicsPath();


//Add all the vertical lines to the path

for(int i=0;i<CounterArray.Count;i++)

{

myPath.AddLine(i,this.panel1.Height,i,this.panel1.Height -
(int)CounterArray);

}

// Close the Path

myPath.AddLine(CounterArray.Count,this.panel1.Height -
(int)CounterArray[CounterArray.Count -1],CounterArray.Count,this.panel1.Heig
ht);


this.panel1.Region=new Region(myPath);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Drawing A Pixel 6
Drawing on a panel 2
Which solution is best 6
about some drawing 1
Graphics Drawing in Form Load 5
some problems with drawing 1
about some easy drawing 1
building up a bitmap 5

Top