Professional Documents
Culture Documents
Appendix A: Using Filled Shapes and Images
Appendix A: Using Filled Shapes and Images
Overview
Types of Brushes for Filled Shapes How to Create Solid and Texture Filled Shapes How to Create Hatch Filled Shapes How to Create a Gradient Filled Shape
Solid Brush
Texture Brush
Hatch Brush
Gradient Brush
Use the Image class with the SolidBrush to create a solid filled shape
CodeExample
Use the Image class and the TextureBrush to create a texture pattern
CodeExample
The HatchBrush object creates a hatched line fill pattern The HatchBrush constructor takes three arguments
CodeExample
Use a path gradient brush to customize the way you fill a shape with gradually changing colors
CodeExample
CodeExample
Customize brushes
10 min
What Is a Bitmap Image? How to Load and Display an Image How to Crop and Scale Images How to Rotate, Skew, and Reflect Images
Bitmap
A bitmap is an array of bits that specify the color of each pixel in a rectangular array of pixels Used for saving bitmaps in disk files BMP, GIF, JPEG, EXIF, PNG, TIFF
Use the Bitmap class for working with bitmap images To load and display a bitmap
Create a Bitmap object and pass the name of the image to the Bitmap constructor Pass that Bitmap object to the DrawImage method of a Graphics object
CodeExample
To crop and scale images specify the size of the rectangle as the desired image size
CodeExample
Specify destination points for the upper-left, upper-right, and lower-left corners of the original image
(100, 0) x (200, 20) is the destination for (0, 0)
(0, 0)
(0, 50)
CodeExample
Dim image = New Bitmap("Compass.bmp") Dim pThumbnail As Image = image.GetThumbnailImage(100, 100, Nothing, _ New IntPtr()) e.Graphics.DrawImage( _ pThumbnail, _ 10, _ 10, _ pThumbnail.Width, _ pThumbnail.Height)
10 min