Lec16 - Lecture 16: Introduction to C# Graphics PIC 10C...

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

View Full Document Right Arrow Icon
1 Lecture 16: Introduction to C# Graphics Lecture 16: Lecture 16: Introduction to C# Graphics Introduction to C# Graphics PIC 10C Todd Wittman Todd Wittman GDI • The C# GDI (Graphics Device Interface) allows us to draw shapes, text, and images on our controls. • Today we will learn about basic drawing, which is similar to the cwin library you played with in PIC 10A. • Drawing is defined in System.Drawing , which is automatically included. • Next week we will talk about building graphics classes, user interaction, and image processing.
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 The Graphics Object First we need something to draw with. Our first step is to create a Graphics object. There are 3 basic ways to create it. 1. In a control's Paint event. private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; 2. Using a control's CreateGraphics() function. Graphics g = button1.CreateGraphics(); 3. Creating from an image. Graphics g = Graphics.FromImage(myImage); Brushes and Pens • Typically we would draw on a Form or Panel control. (The Panel is just a rectangle to put things on, like a GroupBox. For us, it's a canvas.) Graphics g = this.CreateGraphics(); • Now that we have something to draw on, we need something to draw with. • A Pen is used to make shape outlines. • A Brush is used to make solid shapes. Pen myPen = new Pen(Color.Blue, 5);
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

Lec16 - Lecture 16: Introduction to C# Graphics PIC 10C...

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

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