Draw an image on the form
Create a form application. When you click the form, an image is drawn on the form.
Do the following:
① Add a click to the form
Event handling method started
Event processing method from a using
Statement. You use
GDI +
It will use a lot of implementations.
Idisposable
Interface object. If you do not process these objects, they will consume your computer resources until you close the program. So you need a lot
Using
Statement:
② Pay attention to the order of drawing on the form
We need the background of the sky blue, so first draw a blue rectangle, followed by the drawing on it. You need to use the clientrectangle of the form.
It specifies the boundary of the form.
③ Draw bees and flowers
You already know drawimage
() How to use the method.
④ Add a pen for drawing.
When you draw a line, you need to use a pen
Object To define the color and line width. Built-in
Pens
Class provides you with a lot
Pen
. You can also use
Pen
To create its own instance, its constructor must accept
Brush
Object and a floating point number that represents a thick line.
Brush
Is used to draw a fill image, there is
Brushes
Class, it provides you with a variety of color brushes.