views:

66

answers:

1

hi. i have an image where i am resizing the image into thumbnail size it works fine if i am using an image size[700(width)* 600(height)] orignal size lets say i have 10 images of theis size

but if i use an image around size[1100*1200] orignal size it resize the image into thumbnail but doesnot match the size of the other thubnail image

when show in listview control all the images which are size in [700* 600] are shown in one size

image which is in size in [1100* 1200] are shown in one size[slighty smaller than other images]

so when i am displaying the image in listview control so this looks out all 10 images are shown in one size but one image is shown in a smaller size

and some times all the images are loaded fine

but some images are not shown only few images out 10 images 2 images sre not shown

System.Drawing.Image objImage = System.Drawing.Bitmap.FromFile(System.Web.HttpContext.Current.Server.MapPath(@"Images\" + sImageFileName));
if (sImageFileName != null)
{
    if (iThumbSize == 1)
    {

     dHeight = objImage.Height;
     dWidth = objImage.Width;
     dNewHeight = 100;
     dNewWidth = 100;
     objImage = objImage.GetThumbnailImage((int)dNewWidth, (int)dNewHeight, new System.Drawing.Image.GetThumbnailImageAbort(callback), new IntPtr());
}

this i the code what i am using i am setting the size height and width to 100

any help would be great thank you

+1  A: 

I don't see what the problem is with your code, however, I would suggest using a Graphics object to draw the image instead of using Image object.
Here's an example:

Bitmap newImage = new Bitmap(newWidth, newHeight); using (Graphics gr = Graphics.FromImage(newImage)) {
    gr.SmoothingMode = SmoothingMode.AntiAlias;
    gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
    gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
    gr.DrawImage(srcImage, new Rectangle(0, 0, newWidth, newHeight)); }
Galilyou