Windows Develop Bookmark and Share   
 index > Windows Forms General > Chage Image Shapes
 

Chage Image Shapes

Hi,

      I am implementing windows application.  Where i am placing images into the picture boxes up to 10 images into 10 picture boxes and i am providing radio buttons like 1. star, 2. Hear, 3. Circle, 4.  Rectangle and etc..  When user select the radio button then shape of image should be changed to required shape.  Can any one please help to come out this.

Regards,
JeevanRao.Y  
  • Moved byTaylorMichaelLMVPWednesday, October 07, 2009 1:22 PMWinForms related (From:Visual C# General)
  •  
yjeevanrao  Wednesday, October 07, 2009 1:13 PM
You'll probably want to:

1. Create a Bitmap of the correct size.
2. Make a Graphics object for the Bitmap.
3. Draw on the Graphics object.
4. Display the result.

Something like:

    Bitmap bm = new Bitmap(100, 100);
    Graphics gr = Graphics.FromImage(bm);
    gr.DrawEllipse(Pens.Red, 10, 10, 80, 80);
    pictureBox1.Image = bm;

Rod
Rod Stephens  Wednesday, October 07, 2009 2:03 PM
I think you need to create a GraphicsPath object and then use Graphics.FillPath method.
FillPath method needs a Brush object to fill in the path.
In your case this brush object should be a TextureBrush
somecode like

 

 

 

 

protected override void OnPaint(PaintEventArgs e)
{

base.OnPaint(e);
GraphicsPath gp = new GraphicsPath();
//here you need to complete gp object by using its methods //like  AddLine and AddArc to create a custom shape 

using(TextureBrush br = new TextureBrush(Image.FromFile("C:\\temp.jpg")))
{
    br.WrapMode = WrapMode.Tile;
    e.Graphics.FillPath(br, gp);
}

gp.CloseFigure(); 

}

 

 

 

}}}
Koray Samsun  Wednesday, October 07, 2009 3:04 PM

You can use google to search for other answers

Custom Search

More Threads

• trying to covert VS2005 project into VS2008
• Child Form Location Problem
• toolbar buttons - disable
• Initialize System.Windows.Forms.WebBrowser
• OpenFileDialog in local language
• General question - InitializeComponent versus Form_Load
• Having a relative positioning problem with the TabControl
• How can I find the file content when downloading the file?
• Check if config exists
• Dynamice ActiveX