viewing multiple System.Drawing.Image objects

  • Thread starter Thread starter Mike P
  • Start date Start date
M

Mike P

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? I am
using Webforms and not Winforms.
 
Mike P said:
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? I am
using Webforms and not Winforms.

You can add PictureBox controls into the Panel, and them assign your
System.Drawing.Images to the pictureboxes to get them displayed.

If you don't want to use controls, you can implement the Paint event of
the Panel, and then use the GDI+ method DrawImage to directly paint the
Image objects on the panel. But this will probably be more work than the
first solution.
 
Mike P said:
PictureBox is not an available control in Webforms I think, it is not in
my Toolbox.

ARGH! Sorry. I missed the part about using WebForms; both solutions
that I gave you are only useful for WinForms.

On a WebForm, things are somewhat more complicated. You can add <IMG>
controls to your form, and set the "src" attribute to point to a Handler
(.ashx) that delivers a binary response with the contents of your image.
This will require additional work, since this Handler is running separately
from the WebForm, and it doesn't have direct access to the Image objects;
you may consider passing them through the Session. There are many examples
on the net about how to write a handler that serves images, but you will
still need to do some work to pass your specific images from the aspx into
the ashx.
 
Back
Top