Last post Mar 09, 2009 12:10 AM by klpatil
Mar 08, 2009 07:56 PM|Nezdet|LINK
I want to put my logo on uploaded images.
I used this code.. But it enlarges the Logo image and the logo is not getting a good qulity.
string imgPathTemp = Server.MapPath(string.Concat("~/upload/temp/", Images[j].ImageName));
System.Drawing.Image imgTemp = System.Drawing.Image.FromFile(imgPathTemp);
Bitmap bitmapSmall = CreateThumbnail(imgTemp, 80, 60);
bitmapSmall.Save(Server.MapPath(string.Concat("~/upload/final/small/", Images[j].ImageName)), System.Drawing.Imaging.ImageFormat.Jpeg);
Graphics graphTemp = Graphics.FromImage(imgTemp);
System.Drawing.Image imgOverlay = System.Drawing.Image.FromFile(Server.MapPath("~/App_Themes/" + Page.Theme + "/images/videoOverlay.png"));
graphTemp.DrawImage(imgOverlay, imgTemp.Width - imgOverlay.Width - 20, imgTemp.Height - imgOverlay.Height);
imgTemp.Save(Server.MapPath(string.Concat("~/upload/final/large/", Images[j].ImageName)), System.Drawing.Imaging.ImageFormat.Jpeg);
Mar 09, 2009 12:10 AM|klpatil|LINK
I have also faced the same problem the reason is :
Image formats like jpeg may store the thumbnail inside the same file. If we use
System.Drawing.Bitmap method GetThumbnailImage, method checks if there’s a
thumbnail image stored into the file and, if the thumb is found, it returns that
thumbnail version scaled to the width and height you requested. If the
thumbnail version of the image is smaller then the size you requested to produce, thats when problem occurs. The thumbnails produced become pixelated as we know stretching an image to a larger once reduces the
you can try this [it worked for me with little modifications as per my requirement but it will work fine for you i guess..]
Src code of it :
Try this and if it works say thanks to "Manik" who has posted this nice article!!
If any help needed give me a shout ......
"Dream is a heart of life...So keep it beating...Live your dreams!!"