Question

I have a windows service that converts images to black & white and sepia thumbnails. My machine is a 64 bit Windows 7. The server on which I am installing the service is a 32 bit Windows Server 2003.

The code working perfectly on my machine as well as other 64 bit machines but on the server it does not convert images to black & white and sepia.

I have set the Platform target to x86 for my project.

I am using VS 2008 with framework 3.5 and c#.

Following is the code.

    private Bitmap ConvertToBlackAndWhite(Bitmap loImage)
    {
        int height = loImage.Height;
        int width = loImage.Width;

        for (int yCoordinate = 0; yCoordinate < height; yCoordinate++)
        {
            for (int xCoordinate = 0; xCoordinate < width; xCoordinate++)
            {
                //Get the pixel that's at our current coordinate.
                Color color = loImage.GetPixel(xCoordinate, yCoordinate);

                //Calculate the gray to use for this pixel.
                int grayColor = (int)(color.R * 0.3 + color.G * 0.59 + color.B * 0.11);

                //Set the pixel to the new gray color.
                loImage.SetPixel(xCoordinate, yCoordinate, Color.FromArgb(grayColor, grayColor, grayColor));
            }
        }

        return loImage;
    }

I have been trying to google it for quite some time and have not been able to find anything so far.

All help that comes before me going bald is greatly appreciated :). Thanks in advance.

Was it helpful?

Solution

I have been able to resolve the issue. If I process the thumbnail rather than the image itself , the issue goes away. Thanks @mh for pointing it out for me.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top