A Windows Paint
1 Drawing Drawing
1.1 How graphics are plotted
Gets the handle to the paint, device-descriptive descriptor (DC). Use the corresponding Paint API. Drawing graphics on the device
1.2 Colors
RGB, 8 bits per color, 24-bit color
32-bit color: The number of colors 24 is color, and the extra 8 bits represent grayscale.
16-bit: The number of colors is 2 of 16 times.
Under the Win32. The definition of color uses COLORREF. RGB macro-defined color
COLORREF ncolor = RGB (0, 0, 0); Black
COLORREF Ncolor = RGB (255, 255, 255); White
COLORREF Ncolor = RGB (255, 255, 255); Red
Get RGB tri-color from one color value:
int nred = Getrvalue (DWord RGB)
int ngreen = Getgvalue (DWord RGB)
int nblue = Getbvakue (DWord RGB)
1.3-point drawing and acquisition
Drawing: SetPixel
colorref setpixel ( hdc hdc, //Handle to DC int Nxpos , X-coordinate of Pixel int nypos, //Y-coordinate of Pixel
COLORREF crcolor//color value
);
Get: GetPixel
colorref GetPixel ( hdc hdc, //Handle to DC int nxpos, //X-coordinate of pixel int nypos //Y-coordinate of Pixel);
1.4 Drawing of a line
Movetoex move the current point to the specified position
LineTo to the specified position before drawing from the current point
1.5 drawing of Arcs
Arc and ANGLEARC provide different ways to draw arcs
BOOL Anglearc ( hdc hdc, //Handle to device context int X , X-coordinate of Circle ' s Center Center x coordinate int Y, //Y-coordinate of Circle ' s Center Center y-coordinate DWORD dwradius, radius of the park FLOAT estartangle, //ARC ' s start angle start angle FLOAT Esweepangle //ARC ' s sweep angle angle );
How arcs are split
int Setarcdirection (
hdc hdc, //Handle to device context int arcdirection //New arc direction);
BOOL ARC (hdc hdc , //handle to device Context
int
nleftrect
, //X-coord of rectangle ' s upper-left corner
Int
ntoprect
, //Y-coord of rectangle ' s upper-left corner
int
nrightrect< /em> , //X-coord of rectangle ' s lower-right corner int nbottomrect , //Y-coord of rectangle ' s lower-right corner bounding rectangle coordinates int nxstartarc , //X-coord of first radial ending point int nystartarc , //Y-coord of first Radial ending point int nxendarc , //X-coord of second radial ending point int Nyendarc //Y-coord of second radial ending point );
16 percent-wire
BOOL Polyline ( hdc hdc, //Handle to device context CONST point *lppt, //array of endpoints int cpoints Number of points in array);
BOOL PolylineTo ( hdc hdc, //Handle to device context CONST Point *lppt, //array of points DWORD Ccount //number of points in array); similar to Polyline, before drawing polyline. Draws a line from the current point to the first vertex of the polyline using LineTo
BOOL polypolyline ( hdc hdc, //Handle to device context CONST Point *lppt, // array of points all point arrays CONST DWORD *lpdwpolypoints, //array of values per set of points DWORD ccount Number of entries in Values array group );
1.7 Bizer Curve
BOOL polybezier ( hdc hdc, //Handle to device context lppt , Endpoints and control points points Group DWORD cpoints //Count of endpoints and control points Number of points
);
1.8 Fillet Rectangle
BOOL roundrect ( hdc hdc, //Handle to DC int nleftrect, //X-coord of Upper-left corner of rectangle int ntoprect, // Y-coord of Upper-left corner of rectangle int nrightrect, //X-coord of Lower-right corner of rectangle int nbottomrect//Y-coord of Lower-right Corner of rectangle int nwidth, //width of ellipse the ellipse that generated the fillet int nheight //height of ellipse the height of the ellipse that generated the fillet );
1.9 Rectangle
BOOL Rectangle ( hdc hdc, //Handle to DC int nleftrect, //X-coord of Upper-left corner of rectangle int ntoprect, // Y-coord of Upper-left corner of rectangle int nrightrect, //X-coord of Lower-right corner of rectangle int nbottomrect //Y-coord of Lower-right corner of Rectangle);
1.10 Ellipse
BOOL Ellipse ( hdc hdc, //Handle to DC int nleftrect, //X-coord of Upper-left corner of rectangle int ntoprect, // Y-coord of Upper-left corner of rectangle int nrightrect//X-coord of Lower-right Corner of rectangle int nbottomrect //Y-coord of Lower-right corner of Rectangle);
1.11 Pie Pie
BOOL Pie ( hdc hdc, //Handle to DC int nleftrect, //X-coord of Upper-left corner of rectangle int ntoprect, //Y-coord of Upper-left corner of rectangle int nrightrect, //X-coord of Lower-right Corner of rectangle int nbottomrect//Y-coord of Lower-right corner of rectangle< c24> int nXRadial1, //X-coord of First radial ' s endpoint int NYRadial1 , Y-coord of first radial ' s endpoint int nXRadial2, //X-coord of second Radial ' s endpoint int nYRadial2 //Y-coord of second radial ' s endpoint);
1.12 Strings
BOOL Chord ( hdc hdc, //Handle to DC int nleftrect, //X-coord of Upper-left corner of rectangle int ntoprect, // Y-coord of Upper-left corner of rectangle int nrightrect, //X-coord of Lower-right corner of rectangle int nbottomrect//Y-coord of Lower-right Corner of rectangle int nXRadial1, //X-coord of First radial ' s endpoint int NYRadial1 , Y-coord of first radial ' s endpoint int nXRadial2, //X-coord of second Radial ' s endpoint int nYRadial2 //Y-coord of second radial ' s endpoint);
1.13 Multiple variants
BOOL Polygon ( hdc hdc, //Handle to DC CONSTPoint* lpPoints, //polygon vertices int ncount //Count of Polygon vertices);
2 GDI Paint objects-brushes
2.1 Effects of brushes
Ability to control the color, style, width of lines
2.2 Use of brushes
Create a brush
CreatePen
A brush that can be used by the current DC
SelectObject
Draw a graphic
Remove a brush from the current DC
SelectObject
destroying brushes
DeleteObject
3 GDI drawing objects-paint brushes
3.1 Effect of brush
Fills a closed shape, including the style color
3.2 Use of paint brushes
Create a paint brush
Createsilidbrush
Createhatchbrush
A brush that can be used by the current DC
SelectObject
Draw a graphic
Remove Paint brush
SelectObject
Destroy paint brushes
DeleteObject
Win32 Windows Programming Ten