ASP.Net - C# : GDI+: Cut image from drawing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • white007
    New Member
    • Nov 2008
    • 1

    ASP.Net - C# : GDI+: Cut image from drawing

    I am using the following code to generate a semi-ellipse. I want to cut-off the portion below the semi-ellipse and return only the semi-ellipse. Any pointers or path forward will be highly appreciated.

    Code:
    Int32 Radius = 100;
    Int32 X_Coordinate_upper_left_corner = 0;
    Int32 Y_Coordinate_upper_left_corner = 0;
    Int32 Width = 2 * Radius;
    Int32 Height = Radius;
    Bitmap objBitmpCanvas = new Bitmap(Width, Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
    Graphics objGraphics = Graphics.FromImage(objBitmpCanvas);
    Pen objPen = new Pen(Color.Black, 2);
    objGraphics.Clear(Color.White);
    Rectangle objRectangle = new Rectangle(X_Coordinate_upper_left_corner, Y_Coordinate_upper_left_corner, Width, Height);               
    objGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
    objGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
    objGraphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
    objGraphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
    objGraphics.DrawArc(objPen, objRectangle, 0, 180);
    Response.ContentType = "image/gif";
    objBitmpCanvas.Save(Response.OutputStream, ImageFormat.Gif);
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Please enclose your posted code in [CODE] [/CODE] tags (See How to Ask a Question).

    This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

    Please use [CODE] [/CODE] tags in future.

    MODERATOR

    Comment

    Working...