Textured Pens and Brushes

I l @ ve RuBoard

You saw in the previous example that a pen can be given a brush with which to paint the line. Brushes can be solid, gradients, textures, or hatch patterns. A textured brush can be used to draw lines that are painted with a bitmap image. To accomplish this, you can load in a bitmap from a file or a resource, create a brush with it, pass the brush to a pen, and finally draw your lines with the pen. The following snippet of code shows this process:

 Image i=Image.FromFile("stone.bmp"); TextureBrush b= new TextureBrush(i); Pen p=new Pen(b,10); e.Graphics.DrawLine(p,0,0,100,100); p.Dispose(); 

As you can see, a ridiculously simple thing to do.

I l @ ve RuBoard


C# and the .NET Framework. The C++ Perspective
C# and the .NET Framework
ISBN: 067232153X
EAN: 2147483647
Year: 2001
Pages: 204

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net