|
|
[C#]
using (Bitmap bm = new Bitmap(400, 400)) {
using (Graphics graphics = Graphics.FromImage(bm)) {
graphics.Clear(Color.Yellow);
using (Bitmap pattern = (Bitmap)Bitmap.FromFile(Server.MapPath("rez/felix-tchverkin-7pkN83wDZwY-unsplash.jpg"))) {
PointF[] pts = PointF.FromArray(new double[] { 60, 380, 200, 20, 340, 380, 20, 140, 380, 140 });
TextureBrush texture = new TextureBrush(pattern);
graphics.FillPolygon(texture, pts);
}
}
bm.Save(Server.MapPath("IG8_TextureBrush.jpg"));
}
The page draws a closed polygon in the shape of a star filling
it with a pattern. It then saves the image out as a jpeg. The input
and output images are shown below.

felix-tchverkin-7pkN83wDZwY-unsplash.jpg

IG8_TextureBrush.jpg
|