I have this code that transforms a bitmap to its negative:
Code:
        public Bitmap Transform(Bitmap source)
        {
            //create a blank bitmap the same size as original
            Bitmap newBitmap = new Bitmap(source.Width, source.Height);

            //get a graphics object from the new image
            Graphics g = Graphics.FromImage(newBitmap);

            // create the negative color matrix
            ColorMatrix colorMatrix = new ColorMatrix();
            colorMatrix.Matrix00 = colorMatrix.Matrix11 = colorMatrix.Matrix22 = -1f;
            colorMatrix.Matrix33 = colorMatrix.Matrix44 = 1f;

            // create some image attributes
            ImageAttributes attributes = new ImageAttributes();

            attributes.SetColorMatrix(colorMatrix);

            g.DrawImage(source, new Rectangle(0, 0, source.Width, source.Height),
               0, 0, source.Width, source.Height, GraphicsUnit.Pixel, attributes);

            //dispose the Graphics object
            g.Dispose();
            return newBitmap;
        }
This works great on Windows XP. However, when I'm compiling and running the same on Windows 7 (regardless I do it from Visual Studio 2008 or Visual Studio 2010 Beta 2) I only get a black image. All the pixels are black (255, 0, 0, 0).

The only conclusion I can draw is that there is a failure in GDI+, because it cannot have anything to do with the framework (as I said, regardless I build with 3.5 or 4.0, it's the same).

Any ideas what is the problem? Thank you.