Lec17 - Lecture 17 Persistent Graphics PIC 10C Todd Wittman...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Lecture 17: Persistent Graphics PIC 10C Todd Wittman Practice Practice Practice s The goal of today's lecture is to get some more practice drawing graphics. s Ex Draw an anti-Flanders sign. s Can you modify the program so that the user can change the string inside? FLANDERS
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 Disappearing Graphics s When we minimize or cover up the screen, the graphics disappear. s The graphics we draw are not persistent . s There are a couple ways to make graphics persistent. s One way is to define all drawing in the Paint() method. The program calls Paint every few seconds and whenever the screen needs to be redrawn. s But this is awkward. Persistent Graphics s Another solution is to create an image canvas to draw upon. Our Paint() method will then call up this image. s The basic steps are: 1. Create a private Bitmap variable. 2. Initialize the Bitmap when the Form loads. 3. Tell Paint() to show the Bitmap using DrawImage() . 4. Whenever you draw, draw on the Bitmap using the FromImage() method.
Background image of page 2
3 Persistent Graphics: Initializing a Bitmap s Create a Bitmap variable and initialize it to size of the Form. private Bitmap myCanvas; private void Form1_Load(object sender, EventArgs e) { myCanvas = new Bitmap (this.ClientRectangle.Width, this.ClientRectangle.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 6

Lec17 - Lecture 17 Persistent Graphics PIC 10C Todd Wittman...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online