locked
Scaling red images RRS feed

  • Question

  • User-1002471015 posted
    I have a HTTP Handler that resizes images on the fly, it works fine apart from scaling down red images ([url="http://www.ashopcalledwood.com/manufacturercategory-12-T_Shirts-17-Tonite_Girls.aspx"]see here[/url] red t-shirt), has anyone come across this before?

    The code I wrote to resize is

    private System.Drawing.Image _image;

    public void Scale(int width, int height)
            {
                using (Bitmap thumb = new Bitmap(width, height, PixelFormat.Format64bppArgb))
                using (_image)
                {
                    thumb.SetResolution(
                        _image.HorizontalResolution,
                        _image.VerticalResolution);

                    using (Graphics g = Graphics.FromImage(thumb))
                    {
                        g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                        g.DrawImage(
                            _image,
                            new Rectangle(0, 0, thumb.Width, thumb.Height),
                            new Rectangle(0, 0, _image.Width, _image.Height),
                            GraphicsUnit.Pixel);

                        thumb.Save(HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    }
                }
            }

    Sunday, October 30, 2005 1:54 PM

All replies

  • User852353370 posted
    I'm not sure I see the issue. Are you referring to the blotchiness of the image?

    I would guess that the red image is composed of few enough colors that when you scale it, it doesn't result in a smooth enough gradient. Therefore, the "problem" is the original image, not the scaling itself.

    Good luck.
    Sunday, October 30, 2005 4:11 PM
  • User-1002471015 posted
    I'm not sure I see the issue. Are you referring to the blotchiness of the image?

    I would guess that the red image is composed of few enough colors that when you scale it, it doesn't result in a smooth enough gradient. Therefore, the "problem" is the original image, not the scaling itself.

    Good luck.


    Yeah, it's the blotchiness, you can see the orignal image by clicking the link underneath it which is fine
    Sunday, October 30, 2005 5:20 PM