Click here to Skip to main content
15,893,790 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to cut a piece of a picture in the c#.
what can i do?
please help me.
thanks.
Posted
Updated 5-May-11 2:20am
v2
Comments
Tarun.K.S 5-May-11 8:20am    
Edit: Removed mail-id.
Olivier Levrey 5-May-11 8:21am    
Did you try something?

1 solution

Try:
public static Bitmap Extract(Bitmap src, Rectangle section)
    {
    Bitmap bmp = new Bitmap(section.Width, section.Height);
    using (Graphics g = Graphics.FromImage(bmp))
        {
        g.DrawImage(src, 0, 0, section, GraphicsUnit.Pixel);
        }
    return bmp;
    }
 
Share this answer
 
Comments
#realJSOP 5-May-11 8:32am    
5 - proposed as answer
Oshtri Deka 5-May-11 9:04am    
Good answer.
Sergey Alexandrovich Kryukov 5-May-11 18:46pm    
Looks correct, but only if this is rectangular piece.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900