Click here to Skip to main content
15,915,611 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: how FormsAuthentication.SignOut() behaves Pin
Not Active15-Sep-06 6:00
mentorNot Active15-Sep-06 6:00 
QuestionSecured Socket Layers in vb.net 1.1 Pin
amaneet15-Sep-06 4:38
amaneet15-Sep-06 4:38 
QuestionPagepostback.....strange problem Pin
Ritesh123415-Sep-06 4:29
Ritesh123415-Sep-06 4:29 
QuestionSearch Results Count with Gridview Pin
danetix15-Sep-06 3:46
danetix15-Sep-06 3:46 
AnswerRe: Search Results Count with Gridview Pin
Not Active15-Sep-06 3:56
mentorNot Active15-Sep-06 3:56 
AnswerRe: Search Results Count with Gridview Pin
danetix15-Sep-06 4:45
danetix15-Sep-06 4:45 
QuestionHow to restrict the size of image at the time of upload Pin
narendrakumarp15-Sep-06 2:21
narendrakumarp15-Sep-06 2:21 
AnswerRe: How to restrict the size of image at the time of upload Pin
Britney S. Morales15-Sep-06 3:40
Britney S. Morales15-Sep-06 3:40 
You could find you answers at Chris Khoo post

http://www.codeproject.com/aspnet/netimageupload.asp

Based in that post i made these two functions for asp.net C#.

you must to invoice the public function. The parameters are:

MaxWidth = max Width pixels
MaxHeight = max height pixels
UrlAndFileName = the From address image
UrlAndNewFileName = the save address and new file name

Example: (600, 600, "C:\Documents and Settings\Barriosj.FMMB\Mis documentos\Mis imágenes\imagenes\73237_4611.jpg", "c:/myRedimImage.jpg")

The image is restricted by the smallest width or heigth value.

public void Redim_And_SaveImg(int MaxWidth, int MaxHeight, string UrlAndFileName, string UrlAndnewFileName)
{
// load up the image, figure out a "best fit"
// resize, and then save that new image
Bitmap OriginalBmp = (System.Drawing.Bitmap)Image.FromFile(UrlAndFileName).Clone();
Size ResizedDimensions = ObtainDim(MaxWidth, MaxHeight, ref OriginalBmp);
Bitmap NewBmp = new Bitmap(OriginalBmp, ResizedDimensions);
NewBmp.Save(UrlAndnewFileName, System.Drawing.Imaging.ImageFormat.Jpeg);
}


private static Size ObtainDim(int MaxWidth, int MaxHeight, ref Bitmap Bmp)
{
int Width;
int Height;
float Multiplier;

Height = Bmp.Height;
Width = Bmp.Width;

// this means you want to shrink
// an image that is already shrunken!
if (Height <= MaxHeight && Width <= MaxWidth)
return new Size(Width, Height);

// check to see if we can shrink it width first
Multiplier = (float)((float)MaxWidth / (float)Width);
if ((Height * Multiplier) <= MaxHeight)
{
Height = (int)(Height * Multiplier);
return new Size(MaxWidth, Height);
}

// if we can't get our max width, then use the max height
Multiplier = (float)MaxHeight / (float)Height;
Width = (int)(Width * Multiplier);
return new Size(Width, MaxHeight);
}
Smile | :)



keep Learning and you never will be out of date...

QuestionDatagrid problem Pin
Amit Agarrwal15-Sep-06 1:57
Amit Agarrwal15-Sep-06 1:57 
AnswerRe: Datagrid problem Pin
_AK_15-Sep-06 2:01
_AK_15-Sep-06 2:01 
GeneralRe: Datagrid problem Pin
Amit Agarrwal15-Sep-06 2:21
Amit Agarrwal15-Sep-06 2:21 
GeneralRe: Datagrid problem Pin
_AK_15-Sep-06 2:38
_AK_15-Sep-06 2:38 
AnswerRe: Datagrid problem Pin
postmaster@programmingknowledge.com15-Sep-06 2:31
postmaster@programmingknowledge.com15-Sep-06 2:31 
GeneralRe: Datagrid problem Pin
Amit Agarrwal15-Sep-06 2:57
Amit Agarrwal15-Sep-06 2:57 
QuestionPage Details On Back Button Pin
kirthikirthi15-Sep-06 1:46
kirthikirthi15-Sep-06 1:46 
AnswerRe: Page Details On Back Button Pin
_AK_15-Sep-06 2:04
_AK_15-Sep-06 2:04 
QuestionPls help....................... Pin
hai2muru15-Sep-06 1:25
hai2muru15-Sep-06 1:25 
AnswerRe: Pls help....................... Pin
Suresh Pirsquare15-Sep-06 1:29
Suresh Pirsquare15-Sep-06 1:29 
AnswerRubbish subject Pin
J4amieC15-Sep-06 1:40
J4amieC15-Sep-06 1:40 
Questionreports viewer tool problems? Help! Pin
honeyman_can15-Sep-06 1:11
honeyman_can15-Sep-06 1:11 
QuestionDifference among data grid ,datagrid,repeater Pin
rajaragothaman15-Sep-06 1:07
rajaragothaman15-Sep-06 1:07 
QuestionObject Pooling Pin
rajaragothaman15-Sep-06 0:25
rajaragothaman15-Sep-06 0:25 
AnswerRe: Object Pooling Pin
_AK_15-Sep-06 0:30
_AK_15-Sep-06 0:30 
GeneralRe: Object Pooling Pin
rajaragothaman15-Sep-06 0:34
rajaragothaman15-Sep-06 0:34 
GeneralRe: Object Pooling Pin
_AK_15-Sep-06 0:40
_AK_15-Sep-06 0:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.