Making a bitpmap fit into a rounded Rectangle

vis781

Well-known member
Joined
Aug 30, 2005
Messages
2,016
Location
Cambridge, UK
Programming Experience
5-10
As you can probably guess from the title, i am trying to add a skinning property to my usercontrol. I can make a bitmap fit into the rectangle ok, it's just that it fills the whole rectangle whereas i only want it to fit into my graphics path which is a rounded rectangle. I have tried using the get bounds method but that doesn't work.Anyone got any ideas Please?!
 
You can create a System.Drawing.TextureBrush from the bitmap, then use the System.Drawing.Graphics.FillPath method with that TextureBrush and your GraphicsPath.
 
Glad you got it sorted out. As always with .NET there are many ways to accomplish certain things.
It may have been a typo, but using GraphicsPath.GetBounds as the parameter in the Graphics.SetClip method will set the clipping region to a rectangle since GraphicsPath.GetBounds returns a RectangleF object. I believe you ment to use only the graphicsPath as the parameter.
 
Back
Top