Click here to Skip to main content
15,892,059 members
Home / Discussions / C#
   

C#

 
AnswerRe: Online Exam Using Sqlsqerver in Asp.Net using C#.Net Pin
BobJanova30-Oct-11 22:58
BobJanova30-Oct-11 22:58 
AnswerRe: Online Exam Using Sqlsqerver in Asp.Net using C#.Net Pin
phil.o30-Oct-11 23:26
professionalphil.o30-Oct-11 23:26 
QuestionReading values from xml string Pin
sarang_k30-Oct-11 21:05
sarang_k30-Oct-11 21:05 
AnswerRe: Reading values from xml string Pin
Abhinav S30-Oct-11 22:07
Abhinav S30-Oct-11 22:07 
GeneralRe: Reading values from xml string Pin
BobJanova30-Oct-11 22:59
BobJanova30-Oct-11 22:59 
GeneralRe: Reading values from xml string Pin
Abhinav S30-Oct-11 23:01
Abhinav S30-Oct-11 23:01 
AnswerRe: Reading values from xml string Pin
V.31-Oct-11 3:26
professionalV.31-Oct-11 3:26 
QuestionHOw to resize Images in C#/Asp.NET Pin
Software200730-Oct-11 17:25
Software200730-Oct-11 17:25 
-I am trying to learn how to load up a Gallery of images to asp website.I understand I could load thumbnail images to reduce original size. Here is some code I tried after googling, but its still loading original size.
-Also, Can I make these images look more alive, like clikable, or double their size whenclicked?
C#
protected void btnsave_Click(object sender, EventArgs e)
        {
            string filename = Path.GetFileName(fileupload1.PostedFile.FileName);
            string targetPath = Server.MapPath("Images/" + filename);
            Stream strm = fileupload1.PostedFile.InputStream;
            var targetFile = targetPath;
            //Based on scalefactor image size will vary
            GenerateThumbnails(0.5, strm, targetFile);
            BindDataList();
        }
    
private void GenerateThumbnails(double scaleFactor, Stream sourcePath,string targetPath)
        {
            using (var image = System.Drawing.Image.FromStream(sourcePath))
            {
                // can given width of image as we want
                var newWidth = (int)(image.Width * scaleFactor);
                // can given height of image as we want
                var newHeight = (int)(image.Height * scaleFactor);
                var thumbnailImg = new Bitmap(newWidth, newHeight);
                var thumbGraph = Graphics.FromImage(thumbnailImg);

                thumbGraph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                thumbGraph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                thumbGraph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                var imageRectangle = new Rectangle(0, 0, newWidth, newHeight);
                thumbGraph.DrawImage(image, imageRectangle);
                thumbnailImg.Save(targetPath, image.RawFormat);
            }
        }
protected void BindDataList()
        {
            DirectoryInfo dir = new DirectoryInfo(MapPath("~/Images"));
            FileInfo[] files = dir.GetFiles();
            ArrayList listItems = new ArrayList();
            foreach (FileInfo info in files)
            {
                listItems.Add(info);
            }
            dtlist.DataSource = listItems;
            dtlist.DataBind();
        }


modified 30-Oct-11 23:34pm.

AnswerRe: HOw to resize Images in C#/Asp.NET Pin
Software200731-Oct-11 7:30
Software200731-Oct-11 7:30 
AnswerRe: HOw to resize Images in C#/Asp.NET Pin
Sean A. Hanley1-Nov-11 9:17
Sean A. Hanley1-Nov-11 9:17 
AnswerRe: HOw to resize Images in C#/Asp.NET Pin
BillWoodruff1-Nov-11 17:12
professionalBillWoodruff1-Nov-11 17:12 
AnswerRe: HOw to resize Images in C#/Asp.NET Pin
BillWoodruff1-Nov-11 20:17
professionalBillWoodruff1-Nov-11 20:17 
QuestionNested foreach is a bad practice?(please read) Pin
teknolog12330-Oct-11 3:40
teknolog12330-Oct-11 3:40 
AnswerRe: Nested foreach is a bad practice?(please read) Pin
phil.o30-Oct-11 4:14
professionalphil.o30-Oct-11 4:14 
GeneralRe: Nested foreach is a bad practice?(please read) Pin
teknolog12330-Oct-11 4:20
teknolog12330-Oct-11 4:20 
GeneralRe: Nested foreach is a bad practice?(please read) Pin
phil.o30-Oct-11 4:51
professionalphil.o30-Oct-11 4:51 
GeneralRe: Nested foreach is a bad practice?(please read) Pin
teknolog12330-Oct-11 4:59
teknolog12330-Oct-11 4:59 
GeneralRe: Nested foreach is a bad practice?(please read) Pin
BobJanova30-Oct-11 23:03
BobJanova30-Oct-11 23:03 
GeneralRe: Nested foreach is a bad practice?(please read) Pin
phil.o31-Oct-11 0:37
professionalphil.o31-Oct-11 0:37 
AnswerRe: Nested foreach is a bad practice?(please read) Pin
PIEBALDconsult30-Oct-11 5:54
mvePIEBALDconsult30-Oct-11 5:54 
GeneralRe: Nested foreach is a bad practice?(please read) Pin
teknolog12330-Oct-11 7:31
teknolog12330-Oct-11 7:31 
GeneralRe: Nested foreach is a bad practice?(please read) Pin
BillWoodruff30-Oct-11 19:14
professionalBillWoodruff30-Oct-11 19:14 
GeneralRe: Nested foreach is a bad practice?(please read) Pin
PIEBALDconsult31-Oct-11 5:30
mvePIEBALDconsult31-Oct-11 5:30 
Answeriterate each list at most once Pin
Luc Pattyn31-Oct-11 7:20
sitebuilderLuc Pattyn31-Oct-11 7:20 
GeneralRe: iterate each list at most once Pin
PIEBALDconsult1-Nov-11 6:48
mvePIEBALDconsult1-Nov-11 6:48 

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.