Help with Images Required
-
Hi, I am writing an ASP.NET application with c# code-behind. I have a
System.Drawing.Bitmap
variable which funnily enough contains a bitmap image. How can I display this bitmap on an aspx page??? The standard image box will only accept an image source. Thanks Peter -
Hi, I am writing an ASP.NET application with c# code-behind. I have a
System.Drawing.Bitmap
variable which funnily enough contains a bitmap image. How can I display this bitmap on an aspx page??? The standard image box will only accept an image source. Thanks PeterI think you have to store the object temporarily on the disk. I have used the following code for this you may try it:- System.Drawing.Image ObjFullImage; ObjFullImage=System.Drawing.Image.FromFile(Server.MapPath("..") + "//" + StrFile); ObjFullImage.Save(Server.MapPath("..//" + StrFile), ImageFormat.Bmp); I hope this will help you, let me know. Happy coding.:cool: I am a Software Developer using C# on ASP.NET.
-
Hi, I am writing an ASP.NET application with c# code-behind. I have a
System.Drawing.Bitmap
variable which funnily enough contains a bitmap image. How can I display this bitmap on an aspx page??? The standard image box will only accept an image source. Thanks PeterYou can also wrap up the
Bitmap
in an ASPX page and reference that as the SRC for an image element. In the ASPX page you then stream the Bitmap out and the browser will display it correctly. Here is some sample code that I used (C#).private void Page_Load(object sender, System.EventArgs e)
{
long fileSize;
FileStream filestream = new FileStream(Server.MapPath(".") + @"\tracker.jpg" ,FileMode.Open);
fileSize = filestream.Length;byte\[\] Buffer = new byte\[fileSize\]; filestream.Read(Buffer, 0, Convert.ToInt32(fileSize.ToString())); filestream.Close(); Response.BinaryWrite(Buffer);
regards, Paul Watson Bluegrass South Africa Christopher Duncan quoted: "All Corvettes are red. Everything else is just a mistake." Crikey! ain't life grand? Einstein says...
-
Hi, I am writing an ASP.NET application with c# code-behind. I have a
System.Drawing.Bitmap
variable which funnily enough contains a bitmap image. How can I display this bitmap on an aspx page??? The standard image box will only accept an image source. Thanks PeterYou can stream you image to web without saving it to disk. Create an empty ASPX page, and put in something like this:
protected override void OnLoad(System.EventArgs e)
{
base.OnLoad(e);Response.Clear(); Response.ContentType = "image/jpeg"; System.Drawing.Image image = _SomeFunctionThatGetsYourImage_(_someParametersToDecideWhichOne_); image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
}
If you are going to use this image in a webpage, you could in that webpage link to the above mentioned page with the
<img src="_pagename_.aspx">
tag. (I would perhaps use a Querystring variable to tell what image to stream...)
Have a look at my latest article about Object Prevalence with Bamboo Prevalence.