FileUpload Control & Image Control

E

eamon

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
 
S

Steve C. Orr [MVP, MCSD]

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;}
 
E

eamon

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 said:
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;}



eamon said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top