Example #1
0
 public static void CreateThumbnail(FileInfo image, Image img, int maxWidth, int maxHeight)
 {
     if (image.Width > image.Height)
     {
         // Landscape
         if (image.Width > maxWidth)
         {
             img.Width  = maxWidth;
             img.Height = Convert.ToInt32((image.Height * maxWidth) / (float)image.Width);
         }
         else
         {
             img.Width  = image.Width;
             img.Height = image.Height;
         }
     }
     else
     {
         // Portrait
         if (image.Height > maxHeight)
         {
             img.Width  = Convert.ToInt32((image.Width * maxHeight) / (float)image.Height);
             img.Height = maxHeight;
         }
         else
         {
             img.Width  = image.Width;
             img.Height = image.Height;
         }
     }
 }
Example #2
0
 public static void CreateThumbnail(FileInfo image, Image img, int maxWidth, int maxHeight)
 {
     if (image.Width > image.Height)
     {
         // Landscape
         if (image.Width > maxWidth)
         {
             img.Width = maxWidth;
             img.Height = Convert.ToInt32((image.Height*maxWidth)/(float) image.Width);
         }
         else
         {
             img.Width = image.Width;
             img.Height = image.Height;
         }
     }
     else
     {
         // Portrait
         if (image.Height > maxHeight)
         {
             img.Width = Convert.ToInt32((image.Width*maxHeight)/(float) image.Height);
             img.Height = maxHeight;
         }
         else
         {
             img.Width = image.Width;
             img.Height = image.Height;
         }
     }
 }