Do your mean you want to output a Bitmap class object by using Response output stream?
Please feel free to correct me if I have misunderstood your concern.
Here is a demo about how you can do this, please check the code snippet below.
//File: Bitmap_Response_Image.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls; using System.Drawing;
using System.Drawing.Imaging;
Regards,
Xun Ye.
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that
helps you, and to click “Unmark as Answer” if a marked post
does not actually answer your question. This can be beneficial
to other community members reading the thread.
Marked as answer by Xun Ye - MSFT on Jan 14, 2008 06:03 AM
atulkatare
Member
19 Points
40 Posts
Render Image Using Response Object
Jan 09, 2008 11:30 AM|LINK
Hi
i want to render image using Response object for that i am create User Control on Page load crating a bitmap image
{
CaptchaImage ciCaptchaImage = new CaptchaImage(Session["CaptchaImageText"].ToString(), 200, 50, "Century Schoolbook");
//this.Response.Clear();
this.Response.ContentType = "image/jpeg";
ciCaptchaImage.Image.Save(this.Response.OutputStream, ImageFormat.Jpeg);
writer.Write(ciCaptchaImage);
ciCaptchaImage.Image.Save(Response.Otputstream, ImageFormat.Jpeg);
}
CaptchaImage is class inside that i have create a Bitmap image
then put this user control on page..
its show a Image but display in encoded format
so please help me displaying image ..
Thanks..
asp:image and Response object
Xun Ye - MSF...
Star
9272 Points
792 Posts
Re: Render Image Using Response Object
Jan 11, 2008 07:18 AM|LINK
Hi atulkatare,
Do your mean you want to output a Bitmap class object by using Response output stream?
Please feel free to correct me if I have misunderstood your concern.
Here is a demo about how you can do this, please check the code snippet below.
//File: Bitmap_Response_Image.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Drawing.Imaging;
public partial class Bitmap_Response_Image : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string BasePath = Server.MapPath(".");
Bitmap Img, ImgTemp;
ImgTemp = new Bitmap(BasePath + "\\images\\test.jpg");
Img = new Bitmap(ImgTemp, 300, 450);
Graphics Graph;
Graph = Graphics.FromImage(Img);
Img.Save(Response.OutputStream, ImageFormat.Jpeg);
Graph.DrawImage(Img, 0, 0);
ImgTemp.Dispose();
Img.Dispose();
}
}
Regards,
Xun
Xun Ye.
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that
helps you, and to click “Unmark as Answer” if a marked post
does not actually answer your question. This can be beneficial
to other community members reading the thread.
narangrajeev
Member
22 Points
5 Posts
Re: Render Image Using Response Object
May 04, 2012 06:28 PM|LINK
This works perfect. I was using a diffrent way earlier which is now not working on latest browsers. Thanks.