ImageAttributes.SetWrapMode Method (WrapMode)
Sets the wrap mode that is used to decide how to tile a texture across a shape, or at shape boundaries. A texture is tiled across a shape to fill it in when the texture is smaller than the shape it is filling.
Assembly: System.Drawing (in System.Drawing.dll)
Calling the SetWrapMode(WrapMode, Color) and passing Color.Black for the color parameter. Color.Black specifies the color of pixels outside of a rendered image. This color is visible if the mode parameter is set to Clamp and the source rectangle passed to the DrawImage method is larger than the image itself.method is equivalent to calling
Opens an Image from the Circle3.jpg file (a small, red-filled circle) and draws it to the screen.
Creates a TextureBrush using the image from the Circle3.jpg file.
Draws a rectangle to the screen that is filled with the small, red-filled circles.
Public Sub SetWrapModeExample(ByVal e As PaintEventArgs) ' Create a filled, red circle, and save it to Circle3.jpg. Dim myBitmap As New Bitmap(50, 50) Dim g As Graphics = Graphics.FromImage(myBitmap) g.Clear(Color.White) g.FillEllipse(New SolidBrush(Color.Red), New Rectangle(0, 0, _ 25, 25)) myBitmap.Save("Circle3.jpg") ' Create an Image object from the Circle3.jpg file, and draw ' it to the screen. Dim myImage As Image = Image.FromFile("Circle3.jpg") e.Graphics.DrawImage(myImage, 20, 20) ' Set the wrap mode. Dim imageAttr As New ImageAttributes imageAttr.SetWrapMode(WrapMode.Tile) ' Create a TextureBrush. Dim brushRect As New Rectangle(0, 0, 25, 25) Dim myTBrush As New TextureBrush(myImage, brushRect, imageAttr) ' Draw to the screen a rectangle filled with red circles. e.Graphics.FillRectangle(myTBrush, 100, 20, 200, 200) End Sub
Available since 1.1