Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

viewing multiple System.Drawing.Image objects

Status
Not open for further replies.

mjd3000

Programmer
Apr 11, 2009
136
GB
I am creating a number of System.Drawing.Image objects in my code, and I want to be able to add them to an object such as a Panel so that I can view them all together on screen. Is there a way to do this?
 
you can dynamically load images using a generic handler, or a registered implementation of IHttpHandler in the web.config. This handler would be responsible for creating the Image and loading the binary stream into the httpresponse. there are examples of this online. the most common is loading an image from a database. you would swap the database code for your code.

the image tag would point to the handler
Code:
<img src="imagemanager.ashx?[query string goes here]" />
I'm writing this form memory, so the objects or member names may be incorrect. but the handler will look something like this.
Code:
class ImageManager : IHttpHandler
{
     public void Process(HttpContext context)
     {
        var something = context.Request.QueryString["key"];
        var image = new Image();
        image.Load(...);
        context.Response.ContentType = "image/jpg";
        context.Response.WriteBinary(image.ToBinary());
     }

     IsReusable { get { return false; } }
}
what is important to note:
1. reusable is false
2. how to pull the values from the query string
3. set the correct content type
4. put the binary value of the image into the response stream

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top