title: C# ImageButton Picture Resolution
body: <p>I'm trying to make a simple picture thumbnail application.  I've searched the web and have found fairly complicated thumbnail apps, to simple ones.  I have a good one working, If I could get the ImageButton Resolution looking good.  Currently, everything works fine, but the resoultion of the buttons is horrible (i've tried various width/height variations).  </p>
  
  <p>I simply iterate through an array of button Image's and set their properties.  I call ThumbnailSize() to set the width/height of the Imagebutton. </p>
  
  <p>The code is kind of sloppy as of right now, but thats besides the point.  I want to know if there is a way to keep or increase the ImageButton resolution while taking a picture (800x600+/-) and shrinking it into a Imagebutton.</p>
  
  <pre><code>string[] files = null;
  files = Directory.GetFiles(Server.MapPath("Pictures"), "*.jpg");
  
      ImageButton[] arrIbs = new ImageButton[files.Length];
  
      for (int i = 0; i &lt; files.Length; i++)
      {
  
          arrIbs[i] = new ImageButton();
          arrIbs[i].ID = "imgbtn" + Convert.ToString(i);
          arrIbs[i].ImageUrl = "~/Gallery/Pictures/pic" + i.ToString() + ".jpg";
  
          ThumbNailSize(ref arrIbs[i]);
          //arrIbs[i].BorderStyle = BorderStyle.Inset;
  
          arrIbs[i].AlternateText = System.IO.Path.GetFileName(Convert.ToString(files[i]));
          arrIbs[i].PostBackUrl = "default.aspx?img=" + "pic" + i.ToString();
  
          pnlThumbs.Controls.Add(arrIbs[i]);
  
      }
  
  
  }
  public ImageButton ThumbNailSize(ref ImageButton imgBtn)
  {
      //Create Image with ImageButton path, and determine image size
      System.Drawing.Image img =
          System.Drawing.Image.FromFile(Server.MapPath(imgBtn.ImageUrl));
  
      if (img.Height &gt; img.Width)
      {
          //Direction is Verticle
          imgBtn.Height = 140;
          imgBtn.Width = 90;
  
          return imgBtn;
  
      }
      else
      {
          //Direction is Horizontal
          imgBtn.Height = 110;
          imgBtn.Width = 130;
          return imgBtn;
      }
  
  
  }
  </code></pre>