problem with drawing a polygon
-
I want to draw a polygon using Graphic class on a webform, I use the following code but it doesn't show anything!!! :doh:
protected void Page_Load(object sender, EventArgs e)
{
Bitmap objBitmap;
Graphics objGraphics;objBitmap = new Bitmap(400, 440); objGraphics = Graphics.FromImage(objBitmap); objGraphics.Clear(Color.Blue); }
even I delete all the HTML tag except
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ImageResults.aspx.cs" Inherits="Yadgirandeh.WebForm5" %>;
I would be really grateful if anybody helps me.
-
I want to draw a polygon using Graphic class on a webform, I use the following code but it doesn't show anything!!! :doh:
protected void Page_Load(object sender, EventArgs e)
{
Bitmap objBitmap;
Graphics objGraphics;objBitmap = new Bitmap(400, 440); objGraphics = Graphics.FromImage(objBitmap); objGraphics.Clear(Color.Blue); }
even I delete all the HTML tag except
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ImageResults.aspx.cs" Inherits="Yadgirandeh.WebForm5" %>;
I would be really grateful if anybody helps me.
You need to set the response type of the response, and then write the bitmap to the output stream of the response. Something like (after your existing code)...
Response.ContentType = "image/jpeg"; Response.Clear(); Response.BufferOutput = true; objBitmap.Save(Response.OutputStream, ImageFormat.Jpeg); Response.Flush();
Assuming your other code is correct which I haven't really checked.