Changing the gamma of pictures in max-buttons
NOTE: this script has been updated. Read about it in this article.
The gamma settings which are set in the preferences of 3ds max influence the display of colours in the viewport. Max corrects the display of these colors according to whatever setting you might put there. The images in buttons in rollouts and scripts are not corrected. This means pictures in buttons can look either too dark or too light, depending on the gamma setting. There is a way to fix this.
According to the maxscript reference you can’t change the gamma of an image loaded from disk. It’s a read-only property. To work around this, you can set the gamma-setting of the entire application just before you load the image into the button. After the button has been loaded you reset the gamma-setting to whatever value it had. Check out the script for the inner workings. Here’s the essence of it:
myOriginalGamma = fileIngamma --store the current input gamma
fileIngamma = 1.0 --set the gamma for the correct display
picButton.images = #(myImage, undefined,1,1,1,1,1) --set the image to the button
fileIngamma = myOriginalGamma --set the gamma back to whatever it was
This is the demo showing that you can change the gamma-appearance of picturebuttons.
3 Comments
Join the discussion and tell us your opinion.
You can also create a new bitmap with the size and width of the original image and with a gamma you can define, (lookup the bitmap create parameters) and then copy the original image in the new image. I have to say changing gamma scares me a bit 🙂 what if a script crashes and you don’t notice it…
-Johan
That’s very interesting, and very true (about the crashing risk). I’ll look into this.
Klaas
Useful, thanks!