Hey all,
I have created a custom control. During my repaint function I am drawing a grid. My thoughts were that instead of drawing the grid I could just save the graphics after the first time, and then redraw the saved image.
I tried two seperate things. First was using
graphics.Save ( ) / graphics.Restore ( savedGraphics )
When I was using that my graphics ended up being completely blank.
I also tried......
Bitmap tempGraphics = new Bitmap ( this.width, this.Height, graphics );
graphics.DrawImage ( Image.FromBitmap ( tempGraphics ) );
The drawimage code I put here isnt the exact code. It was something like Image.FromHBitmap. I dont have it with me at current tho. I also tried saving the created bitmap to a file but it came out blank (tempGraphics.Save ( "test.bmp" ); It was the right width and height however it was just a blank file.
I always saved the graphics once everything was drawn then toggle a flag. Then when drawing again check the flag. If its set its suppost to load the image rather than redraw. Can anyone help me out? Maybe give an example of saving a Graphics object to a file? or even just make an Image or Bitmap of it? Thanks.
I have created a custom control. During my repaint function I am drawing a grid. My thoughts were that instead of drawing the grid I could just save the graphics after the first time, and then redraw the saved image.
I tried two seperate things. First was using
graphics.Save ( ) / graphics.Restore ( savedGraphics )
When I was using that my graphics ended up being completely blank.
I also tried......
Bitmap tempGraphics = new Bitmap ( this.width, this.Height, graphics );
graphics.DrawImage ( Image.FromBitmap ( tempGraphics ) );
The drawimage code I put here isnt the exact code. It was something like Image.FromHBitmap. I dont have it with me at current tho. I also tried saving the created bitmap to a file but it came out blank (tempGraphics.Save ( "test.bmp" ); It was the right width and height however it was just a blank file.
I always saved the graphics once everything was drawn then toggle a flag. Then when drawing again check the flag. If its set its suppost to load the image rather than redraw. Can anyone help me out? Maybe give an example of saving a Graphics object to a file? or even just make an Image or Bitmap of it? Thanks.