User66879988 posted
Dear all, The following is my C# code to draw a line in browser, but it display nothing. Why? private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here Bitmap objBitmap = new Bitmap(200, 100); Graphics objGraphics
= Graphics.FromImage(objBitmap); objGraphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 200, 100); }
User217889999 posted
YOu need to save your image and output it to the browser. Either directly using Response.OutputStream or via the filesystem and an Image tag. Example:
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here Bitmap objBitmap = new Bitmap(500, 500); Graphics objGraphics = Graphics.FromImage(objBitmap); objGraphics.Clear(Color.White); objGraphics.FillRectangle(new
SolidBrush(Color.Black), 0, 0, 400, 1); objBitmap.Save(Response.OutputStream, ImageFormat.Jpeg); }