| Herd Software Development
DaVinci Graphics Library
DaVinci Documentation Home Search Order

Leonardo: The GammaCorrectionApplyToDIB function

The function GammaCorrectionApplyToDIB changes the color representation of a DIB according to the gamma correction.

void API GammaCorrectionApplyToDIB(
int Gamma10000,
int iReserved1,
int iReserved2,
LPBYTE lpabGamma);

HDIB HDIB Handle of the DIB to be adapted

iGamma1000 int Gamma correction value, multiplied by 10000.(see Gamma correction))

iReserved1 int Reserved for future use. Applications should specify this value as 0.

iReserved2 int Reserved for future use. Applications should specify this value as 0.

lpabGamma LPBYTE Pointer to an array of 256 byte values previously computed by GammaCorrectionGetArray, or NULL.


The specified DIB is not returned as a gamma-corrected copy; the source image itself is gamma-corrected resulting in permanent change to the DIB. The process cannot be undone. Create a copy of the DIB prior to execution if needed using CopyHandle.

DIBs which require color palettes (biBitCount <= 8) will only have their palettes modified, so processing speed will be quite rapid. Higher-resolution DIBs require every byte of the DIB to be modified which takes considerably longer.

Example: Apply gamma correction to a DIB.
HDIB GammaCorrect(float Gamma, HDIB hOriginalDIB)
  HDIB hDIB = CopyHandle(hOriginalDIB);
  BYTE Array[256];
  if (hDIB)
     GammaCorrectionGetArray(Gamma * 10000, 0, 0, Array);
     GammaCorrectionApplyToDIB(hDIB, Gamma*10000, 0, 0, Array);
  return hDIB;
} // GammaCorrect