Hopefully you guy can help me with this
I created the script which can resize the image to the highest quality
What happen was, if i use the " InterpolationMode" option (High, HighQualityBicubic or HighQualityBilinear) the picture TURN OUT in a very high quality BUT there was an extra LINE of the TOP and LEFT side of the image.
Script >>>> SmallImg.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
If I use the " InterpolationMode" option (Low,Default,NearestNeighbor,Bicubic or Bilinear) then the picture look a so blur.
Script >>>> SmallImg.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Script >>>> SmallImg.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
Thank you very much for reading my post.
The script is below is the full script that i wrote, please help me here. , All comment is included in the script too.
Please remember to test this script, please use the brighter image else you may not see the problem.
Thank you
<%@ Page Language="C#" %>
<%@Import Namespace="System.Drawing.Imaging" %>
<%@Import Namespace="System.Drawing" %>
<%@Import Namespace="System.IO" %>
"c#" runat="server">
public void Page_Load(Object sender, EventArgs e)
{
//Image source http://imagecache2.allposters.com/images/pic/IMC/P7393~White-Buddha-Posters.jpg string ImageName = "P7393~White-Buddha-Posters.jpg"; // Just use the white, just for easy to see the problem. System.Drawing.Image OriginalImage = System.Drawing.Image.FromFile(Server.MapPath(ImageName)); //Select resize image size int imageHeight = Convert.ToInt32("75"); // The height int imageWidth = Convert.ToInt32("75"); //The width Bitmap SmallBitmap = new Bitmap(imageWidth, imageHeight, OriginalImage.PixelFormat);
Graphics SmallImg = Graphics.FromImage(SmallBitmap);
//SmallImg.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode; //This option is so poor quality
//SmallImg.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;//This option is so poor quality SmallImg.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;// Qualit is great BUT had virtical line on the left and top
// Problem with high, HighQualityBicubic, HighQualityBilinear
//Okay on low,Default,NearestNeighbor,Bicubic,Bilinear,
//SmallImg.Clear(Color.FromArgb(200, 255, 255, 255)); SmallImg.DrawImage(OriginalImage, 0, 0, SmallBitmap.Width, SmallBitmap.Height); //Print to the browser Response.ContentType = "image/jpeg";
SmallBitmap.Save(Response.OutputStream, ImageFormat.Jpeg);
SmallImg.Dispose();
SmallImg.Dispose();
}