FileUpload Control & Image Control

Discussion in 'ASP .Net Web Controls' started by eamon, Aug 4, 2005.

  1. eamon

    eamon Guest

    I would like to know if there is an eventhandler that i can use in order to
    get an image in the image control from the file upload without having use a
    button or is there a way i can get a thumbnail from the fileupload control?

    Please help got a deadline and my boss is checking up on me frequently/
    Thank You all

    Eamon
     
    eamon, Aug 4, 2005
    #1
    1. Advertising

  2. You can resize the image using the GetThumbnailImage method.
    Here's more info:
    http://msdn.microsoft.com/library/d...emDrawingImageClassGetThumbnailImageTopic.asp

    Or maybe you'll find these custom functions I wrote to be useful:

    public Image DisplaySize(Bitmap bmp)
    {
    Response.Write(bmp.Width.ToString());
    Response.Write(bmp.Height.ToString());
    }

    //shrink the image proportionately so that neither height nor width is
    //more than [NewSize] pixels

    public System.Drawing.Image ShrinkImage(System.Drawing.Bitmap bmp, int
    NewSize)

    {

    double NewWidth;

    double NewHeight;

    double ShrinkPercent;

    System.Drawing.Image.GetThumbnailImageAbort myCallback =

    new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);

    if (bmp.Width>bmp.Height)

    {

    NewWidth=NewSize;

    ShrinkPercent=(NewWidth/bmp.Width)*100;

    NewHeight=(ShrinkPercent/100)*bmp.Height;

    }

    else

    {

    NewHeight=NewSize;

    ShrinkPercent=(NewHeight/bmp.Height)*100;

    NewWidth=(ShrinkPercent/100)*bmp.Width;

    }

    System.Drawing.Image myShrunkenImage =
    bmp.GetThumbnailImage((int)NewWidth,(int)NewHeight,myCallback,IntPtr.Zero);

    return myShrunkenImage;

    }

    public bool ThumbnailCallback(){return false;}

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net

    "eamon" <> wrote in message
    news:...
    >I would like to know if there is an eventhandler that i can use in order to
    > get an image in the image control from the file upload without having use
    > a
    > button or is there a way i can get a thumbnail from the fileupload
    > control?
    >
    > Please help got a deadline and my boss is checking up on me frequently/
    > Thank You all
    >
    > Eamon
     
    Steve C. Orr [MVP, MCSD], Aug 4, 2005
    #2
    1. Advertising

  3. eamon

    eamon Guest

    Can anyone convert this code into VB for me please my project isn't compling
    the one below because im using VB.

    "Steve C. Orr [MVP, MCSD]" wrote:

    > You can resize the image using the GetThumbnailImage method.
    > Here's more info:
    > http://msdn.microsoft.com/library/d...emDrawingImageClassGetThumbnailImageTopic.asp
    >
    > Or maybe you'll find these custom functions I wrote to be useful:
    >
    > public Image DisplaySize(Bitmap bmp)
    > {
    > Response.Write(bmp.Width.ToString());
    > Response.Write(bmp.Height.ToString());
    > }
    >
    > //shrink the image proportionately so that neither height nor width is
    > //more than [NewSize] pixels
    >
    > public System.Drawing.Image ShrinkImage(System.Drawing.Bitmap bmp, int
    > NewSize)
    >
    > {
    >
    > double NewWidth;
    >
    > double NewHeight;
    >
    > double ShrinkPercent;
    >
    > System.Drawing.Image.GetThumbnailImageAbort myCallback =
    >
    > new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);
    >
    > if (bmp.Width>bmp.Height)
    >
    > {
    >
    > NewWidth=NewSize;
    >
    > ShrinkPercent=(NewWidth/bmp.Width)*100;
    >
    > NewHeight=(ShrinkPercent/100)*bmp.Height;
    >
    > }
    >
    > else
    >
    > {
    >
    > NewHeight=NewSize;
    >
    > ShrinkPercent=(NewHeight/bmp.Height)*100;
    >
    > NewWidth=(ShrinkPercent/100)*bmp.Width;
    >
    > }
    >
    > System.Drawing.Image myShrunkenImage =
    > bmp.GetThumbnailImage((int)NewWidth,(int)NewHeight,myCallback,IntPtr.Zero);
    >
    > return myShrunkenImage;
    >
    > }
    >
    > public bool ThumbnailCallback(){return false;}
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://SteveOrr.net
    >
    > "eamon" <> wrote in message
    > news:...
    > >I would like to know if there is an eventhandler that i can use in order to
    > > get an image in the image control from the file upload without having use
    > > a
    > > button or is there a way i can get a thumbnail from the fileupload
    > > control?
    > >
    > > Please help got a deadline and my boss is checking up on me frequently/
    > > Thank You all
    > >
    > > Eamon

    >
    >
    >
     
    eamon, Aug 4, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Uncle Ben

    ASP.NET 2.0 FileUpload control

    Uncle Ben, Mar 23, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    3,813
    Bruce Barker
    Mar 23, 2005
  2. Eric

    FileUpload control.

    Eric, Dec 26, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    5,837
    Ankho
    Nov 3, 2009
  3. VB Programmer

    How check filesize using FileUpload control?

    VB Programmer, Jan 18, 2006, in forum: ASP .Net
    Replies:
    11
    Views:
    20,469
  4. Nathan Sokalski
    Replies:
    1
    Views:
    776
    Mark Rae
    Jan 11, 2007
  5. Nathan Sokalski
    Replies:
    0
    Views:
    276
    Nathan Sokalski
    Jan 11, 2007
Loading...

Share This Page