C # GDI + Learning Note 1

Source: Internet
Author: User

? preface

This article is the first article to learn the C # GDI + series, the simple introduction of GDI + some basic drawing content, relatively coarse. But this article is mainly to let everyone briefly review the basic concept of GDI +. Please download the reference code for this article.

Gdiptest_article1_161112_2346.rar

If you have any questions, or suggestions, please leave a message to contact me.

1 window Redraw? Windows automatically handles user actions such as dragging the mouse form, changing the size of the form, automatically resizing the form to occupy the screen area, and redrawing the Windows Send message wm_paint the form object's Paint event when a redraw is required to respond to the WM_PAINT message – When the form is blocked , and show again – when other forms are moved on the main form – – Windows only the necessary areas when the size of the main form is larger, ClipRectangle property – calls the Invalidate method to actively fire WM_PAINT message 2. What is the drawing content? (point)? rectangle (Rectangle)? color? Pen (pen)? Brush (Brush)? (font)? Path (GraphicsPath)? region? NET provides two data structures that represent the coordinate values of a point in a drawing: the location (x, y) and pointf. It encapsulates two variables, one for width and one for height. In most cases, the coordinates, length, and width values specified in the code are all pixels. You can use the PageUnit property of the graphics to determine other units. Rectangle RectangleDoes a point--contains in a rectangle? Zooming in and out of the rectangle: inflate (for positive amplification, negative narrowing)? Two intersection of the rectangles: Intersect? Union: Unions? Translation: Offset ? The HSB model of color? Hue: Hue 0 ... 360? Saturation: Saturation of 0 ... 1? Brightness: Brightness 0 ... 1. Create a Color object: Color clr;clr= color.fromargb (255, 255, 0, 255)? Another method:? Color.fromknowncolor (...)? The alpha value of the color represents the transparency of the color. To create a transparent object, set the alpha value to be less than ' 255 ', Pens (pen)To draw lines, curves, outlines shapes? After you create a Pen object, you can draw different types of lines by setting their properties. Width, Color? StartCap, Endcap: The shape of the start and end points? DashStyle: Set Dash style ? Types of brushes? create solid and texture filled shapes? Create a solid hatch shape? Create a gradient solid shape? Create a pathgradient solid shape? Hands-On Labs: Create transparent and fill graphics ? Brushobject is used to fill graphics? SolidBrush: solid color painting brush? HatchBrush: pattern painting brush? The typical pattern fill graphic provided by – windows? TextureBrush: Textured paint brush? LinearGradientBrush: Gradient brush? – Fills a shape with a smooth transition color? PathGradientBrush: Path gradient brush? – based on a path, fill with a complex blend color gradient? Use the gradient brush to achieve a gradient color? Use the path gradient brush to fill the shape with a gradient color, A color gradient is a smooth color gradient from the midpoint of the path to the outer edge of the path. ? Drawing text? Need a Brush object and a Font object? Call the DrawString method of the Graphics object to draw the text? Draw text skills? Specify the text drawing range: Provide a Rectangle object? control line wrapping: Environment.NewLine? Draw Vertical text: Using the StringFormat object ? GraphicsPathThis class encapsulates a series of connected lines, curves, arcs, and other surrounding shapes. A path can be constructed by using the Add series method, the path is automatically set by the Closefigure method, the path is drawn by the DrawPath method of the graphics, and the FillPath method fills the path ? regional (region)Part of a drawing surface? You can use Rectangle or GraphicsPath objects to construct a region? Use FillRegion to populate a region? Use Makeinfinite to convert a region to an infinite area? Can I do a collection-like operation on a region? You can use a region object to get a form of a special shape ? screen coordinate system? Pan: G.translatetransform (100, 75)? Rotation G.rotatetransform (45) ? Zoom:The scaling of the coordinate system refers to the invariant of the origin of the coordinates, but the number of pixels per unit length varies. Twice times the horizontal magnification, three times times the vertical magnification? G.scaletransform (2.0F, 3.0F) ? Bitmap? – The bitmap is an array of bits that specifies the color of each pixel in the pixel matrix. What type of graphics file format? –bmp, GIF, JPEG, EXIF, PNG, TIFF ? rotate, tilt, and refract images? – Use the DrawImage method and specify the target coordinates in the upper-left, upper-right, and lower-left corners to create thumbnails by calling the Getthumbnailimage method of the Image object output words on an imageGet the Graphics object g of the container where the image object is located, then call G's drawstring;? or get the graphics object of the image itself and call the DrawString method. Create image effects? Image effects are based on the direct operation of the pixel points of the image. The pixel can be mathematically transformed. What is the method? – Call GetPixel to get the color of the point and then, after processing it, write back to the image with SetPixel.

C # GDI + Learning Note 1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.