GDI+ Question: ImageAttributes.SetGamma  
Author Message
ManConfusedByMouse





PostPosted: Visual C# General, GDI+ Question: ImageAttributes.SetGamma Top

Hi,

I am getting unexpected results when I call ImageAttributes.SetGamma. Specifically, calling with a parameter less than 1.0 causes the drawn bitmap to be brighter, and with param more than 1.0 causes the bitmap to come out darker. At least something is happening, but I thought that higher gamma values are associated with increased intensity. (but this may just be my misunderstanding). Is this the way it's supposed to work Thanks for any help...(oh, here is a code fragment)...

ImageAttributes imageAttr = new ImageAttributes();

imageAttr.SetGamma( newGamma );

Bitmap newBitmap = new Bitmap( this.Width, this.Height, this.PixelFormat );

Graphics g = Graphics.FromImage( newBitmap );

Rectangle rect = new Rectangle( new Point( 0, 0 ), new Size( this.Width, this.Height ) );

g.DrawImage( this.Bitmap, rect, 0, 0, this.Width, this.Height, GraphicsUnit.Pixel,

imageAttr ); // image color intensity comes out opposite to what I expected...



Visual C#16  
 
 
PJ. van de Sande





PostPosted: Visual C# General, GDI+ Question: ImageAttributes.SetGamma Top

This is a correct result, your image getting brightes when you higher the Gamma, when you set it to 6.0 you have an allmost white image.


 
 
ManConfusedByMouse





PostPosted: Visual C# General, GDI+ Question: ImageAttributes.SetGamma Top

Thank you for responding, but i was trying to indicate, perhaps not with the greatest skill, that the OPPOSITE was happening for me. The higher the gamma I set, the darker the image gets. If I set it above 1, it gets darker, and below, brighter Can someone spot something wrong with my code

Thanks


 
 
PJ. van de Sande





PostPosted: Visual C# General, GDI+ Question: ImageAttributes.SetGamma Top

Here is have posted to results, first on is with the gamma set to 0.1 and the other one to 5.
The code i used it allmost exactly yours.


 
 
ManConfusedByMouse





PostPosted: Visual C# General, GDI+ Question: ImageAttributes.SetGamma Top

PJ,

thanks for your persistence on this. I'll have to recheck my code. There may be some problem with the way I am passing the parameter into the routine that applies the gamma -- it is pretty bizzare that I am getting "inverted" results...If I have no luck, I'll try posting again.

Thanks


 
 
PJ. van de Sande





PostPosted: Visual C# General, GDI+ Question: ImageAttributes.SetGamma Top

This isn't the Gamma method then, but i think there is a bug in the value you pass trough the SetGamma method.

Try to trace your routine and fix the bug


 
 
neverhome





PostPosted: Visual C# General, GDI+ Question: ImageAttributes.SetGamma Top

I am also having this problem (using VB 2005 Express). The higher the value, the darker the image. Have you (or anyone else out there! ) found a solution

Thanks

AB