Class GammaMgr

3DS Max Plug-In SDK

Class GammaMgr

See Also: Class Color, COLORREF.

class GammaMgr

Description:

The gamma manager class. Methods of this class are used to gamma correct and de-gamma colors in various formats. Various settings from the 3ds max user interface are also accessible via data members of this class (for example the display, and file gamma settings). These settings may be read but should not be set by a plug-in developer. All methods of this class are implemented by the system.

There is a global instance of this class (defined in \MAXSDK\INCLUDE\GAMMA.H):

GammaMgr gammaMgr;

Note the following #defines. These are used to reduce the size of the gamma tables for correcting 16 bit values.

#define RCBITS 13

#define RCOLN (1<<RCBITS)

This class provides a set of commonly used gamma tables. This class does not provide tables for all types of conversion however. For example if you have a different gamma setting that you are using, or if you are going in a different conversion direction than the tables provided here you may use the classes GamConvert16 and GamConvert8 to build gamma tables.

Data Members:

public:

BOOL enable;

Indicates if gamma correction is enabled or disabled.

BOOL dithTrue;

Indicates if output dithering is to be used for true color images.

BOOL dithPaletted;

Indicates if output dithering is to be used for paletted images.

float dispGamma;

The display gamma setting.

float fileInGamma;

The file input gamma setting.

float fileOutGamma;

The file output gamma setting.

UBYTE disp_gamtab[256];

Display gamma table for drawing color swatches (8->8)

UBYTE disp_gamtabw[RCOLN];

Display gamma table (RCBITS->8).

UBYTE file_in_gamtab[256];

File input gamma table (8->8).

UWORD file_in_degamtab[256];

For de-gamifying bitmaps on input. (8->16)

UWORD file_out_gamtab[RCOLN];

Gamma correct for file output, before dither (RCBITS->16).

Methods:

Prototype:

GammaMgr();

Remarks:

Constructor.

Prototype:

inline COLORREF DisplayGammaCorrect(COLORREF col);

Remarks:

Gamma corrects the specified color using the display gamma setting.

Parameters:

COLORREF col

The color to gamma correct.

Return Value:

The gamma corrected color.

Prototype:

Color DisplayGammaCorrect(Color c);

Remarks:

Gamma corrects the specified color using the display gamma setting.

Parameters:

Color c

The color to gamma correct.

Return Value:

The gamma corrected color.

Prototype:

void Enable(BOOL onOff);

Remarks:

Sets the gamma correction enabled setting.

Parameters:

BOOL onOff

TRUE to enable; FALSE to disable.

Prototype:

BOOL IsEnabled();

Remarks:

Returns the gamma correction enabled setting; TRUE if enabled; FALSE if disabled.

Prototype:

void SetDisplayGamma(float gam);

Remarks:

Sets the display gamma setting.

Parameters:

float gam

The value to set.

Prototype:

float GetDisplayGamma();

Remarks:

Returns the display gamma setting.

Prototype:

void SetFileInGamma(float gam);

Remarks:

Sets the file input gamma setting.

Parameters:

float gam

The value to set.

Prototype:

float GetFileInGamma();

Remarks:

Returns the file input gamma setting.

Prototype:

void SetFileOutGamma(float gam);

Remarks:

Sets the file output gamma setting.

Parameters:

float gam

The value to set.

Prototype:

float GetFileOutGamma();

Remarks:

Returns the file output gamma setting.

The following functions are not part of class GammaMgr but are available for use.

Prototype:

inline COLORREF gammaCorrect(DWORD c);

Remarks:

Returns a gamma corrected version of the specified color using the display gamma setting.

Parameters:

DWORD c

The color to gamma correct.

Prototype:

inline UBYTE gammaCorrect(UBYTE b);

Remarks:

Returns a gamma corrected version of the specified color using the display gamma setting.

Parameters:

UBYTE b

The color to gamma correct.

Prototype:

void BuildGammaTab8(UBYTE gamtab[256], float gamma, int onoff=TRUE);

Remarks:

Builds the gamma table that maps 8->8.

Parameters:

UBYTE gamtab[256]

The table to build.

float gamma

The gamma setting.

int onoff=TRUE

TRUE to enable; FALSE to disable.

Prototype:

void BuildGammaTab8(UWORD gamtab[256], float gamma, int onoff=TRUE);

Remarks:

Builds a gamma table that maps 8->16.

Parameters:

UBYTE gamtab[256]

The table to build.

float gamma

The gamma setting.

int onoff=TRUE

TRUE to enable; FALSE to disable.

Prototype:

void BuildGammaTab(UBYTE gamtab[RCOLN], float gamma, int onoff=TRUE);

Remarks:

Build a gamma table that maps RCBITS->8.

Parameters:

UBYTE gamtab[RCOLN]

The table to build.

float gamma

The gamma setting.

int onoff=TRUE

TRUE to enable; FALSE to disable.

Prototype:

void BuildGammaTab(UWORD gamtab[RCOLN], float gamma, int onoff=TRUE);

Remarks:

Build a gamma table that maps RCBITS->16.

Parameters:

UWORD gamtab[RCOLN]

The table to build.

float gamma

The gamma setting.

int onoff=TRUE

TRUE to enable; FALSE to disable.

Prototype:

float gammaCorrect(float v, float gamma);

Remarks:

Gamma corrects the value passed using the specified gamma setting.

Parameters:

float v

The value to gamma correct.

float gamma

The gamma setting.

Return Value:

The gamma corrected value.

Prototype:

float deGammaCorrect(float v, float gamma);

Remarks:

De-gamma corrects the value passed using the specified gamma setting.

Parameters:

float v

The value to de-gamma correct.

float gamma

The gamma setting.

Prototype:

UBYTE gammaCorrect(UBYTE v, float gamma);

Remarks:

Gamma corrects the value passed using the specified gamma setting.

Parameters:

UBYTE v

The value to gamma correct.

float gamma

The gamma setting.

Return Value:

The gamma corrected value.

Prototype:

UBYTE deGammaCorrect(UBYTE v, float gamma);

Remarks:

De-gamma corrects the value passed using the specified gamma setting.

Parameters:

UBYTE v

The value to de-gamma correct.

float gamma

The gamma setting.

Prototype:

UWORD gammaCorrect(UWORD c, float gamma);

Remarks:

Gamma corrects the value passed using the specified gamma setting.

Parameters:

UWORD c

The value to gamma correct.

float gamma

The gamma setting.

Return Value:

The gamma corrected value.

Prototype:

UWORD deGammaCorrect(UWORD c, float gamma);

Remarks:

De-gamma corrects the value passed using the specified gamma setting.

Parameters:

UWORD c

The value to de-gamma correct.

float gamma

The gamma setting.