Raihan Iqbal
Life is codetastic!

Archive for January, 2009

Cheap Web Hosting

Looking for cheap web hosting?? Our cheap price and support make us the obvious choice for web masters.

You look good if your site is fast and always available. We been successfully focusing on Super Fast and Highly Reliable Hosting and the only Bangladeshi provider to offer not just a unique package of features but a philosophy for extracting the best value out of your Internet presence. With us you get the best in high availability hosting using the finest quality hardware and facilities, backing it up with a local personal and highly effective extended hours support service. These, together with performance-guarantees at a competitive price, make us the professional’s choice.

Hosting Features:

  • 99.9% Web Server Uptime guarantee
  • Extensive Data Backup
  • 24 x 7 x 365 Server Monitoring
  • Optional control panel for hands on access
  • Reliable email service
  • Quality visitor monitoring statistics
  • Good server response times
  • Secure servers for confidential transactions
  • Choice of web hosting with a Linux & Windows Server
  • Reliable 24 hour operation, 365 days a year
  • Flexible bandwidth to cope with your peak traffic
  • Sufficient storage space for your site files and databases

For further inquiries, please send us an email with your specs to sales@raihaniqbal.net

Share

Posted in Uncategorized | 643 views | No Comments

Resizing Images In ASP.NET

I’m sure there are plenty of similar topics out there but this is my two cents. Lets say you have the following code in your ASP.NET page:

    1 Upload a File: &nbsp;<asp:FileUpload ID="pictureUpload" runat="server" /><br />

    2 <asp:Button ID="btnUpload" runat="server" Text="Upload" OnCommand="handle_ButtonClick" CommandName="Upload" />

Let’s look at the event handler code that uploads the image to the server and resizes it.

    1     protected void handle_ButtonClick(object sender, CommandEventArgs e)

    2     {

    3         if (e.CommandName == "Upload")

    4         {

    5             if (pictureUpload.HasFile)

    6             {

    7                 string FilePath = HttpContext.Current.Server.MapPath(PATH_FILESFOLDER) + pictureUpload.FileName;

    8                 pictureUpload.SaveAs(FilePath);

    9                 ResizeImageAndSave(FilePath, 90);

   10             }

   11         }

   12     }

   13 

   14     public void ResizeImageAndSave(string FilePath, int Width)

   15     {

   16         Bitmap loBMP = new Bitmap(FilePath);

   17         ImageFormat loFormat = loBMP.RawFormat;

   18 

   19         //*** If the image is smaller than a thumbnail just return it

   20         if (loBMP.Width < Width) return;

   21 

   22         decimal lnRatio = Convert.ToDecimal(Width) / loBMP.Width;

   23         int lnNewWidth = Width;

   24         int lnNewHeight = Convert.ToInt32(loBMP.Height * lnRatio);

   25 

   26         Bitmap bmpOut = new Bitmap(lnNewWidth, lnNewHeight);

   27         Graphics g = Graphics.FromImage(bmpOut);

   28         g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

   29         g.FillRectangle(Brushes.White, 0, 0, lnNewWidth, lnNewHeight);

   30         g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight);

   31 

   32         //Dispose old  BMP object

   33         loBMP.Dispose();

   34 

   35         bmpOut.Save(FilePath);

   36         bmpOut.Dispose();

   37     }

The code is pretty obvious – save the file to the specified path, resize the image, dispose the old image and finally save the new image.

Happy Programming!

Share

Posted in .net, asp.net, c#, Development | 516 views | No Comments