The automatic gamma correction method chooses a gamma value based on the file type when loading a bitmap file (in certain cases) and when saving a bitmap file. You do not need to care about the gamma correction because it is automatically done based on the file type, bit depth, and other properties.
Following are the limitations in the previous method for gamma correction:
In the automatic gamma correction method, if a file header does not contain a gamma value, the file type is considered to determine whether the file must be stored linearly. For more information about automatic gamma correction, see the Automatic Gamma Correction topic.
The mapping of the flags (BMM_CUSTOM_FILEGAMMA
and BMM_CUSTOM_GAMMA
) with the gamma options in the File dialog has changed in the automatic gamma correction method. Additionally, the meaning of the BMM_CUSTOM_FILEGAMMA
flag has also changed. A new BitmapIOMetaData
interface in the BitmapIO
class is used to determine whether the file types are saved and loaded linearly or with an embedded gamma. For more information about the SDK changes, see the SDK Changes for Automatic Gamma Correction topic.
Following are some best practices for avoiding gamma related issues when writing code:
BitmapInfo
and not filenames. If you need to use filenames, avoid changing the extension. If you change the extension, call BitmapInfo::ResetPiData()
.BitmapInfo::GetEffectiveGamma()
if you need to know the gamma of a bitmap and to untangle the various flags correctly. Moreover, it is better to ignore the gamma and always use GetLinearPixels()
(instead of GetPixels()
) to obtain the proper linear value.BitmapIOMetaData
interface if you are writing a BitmapIO
plug-in that needs linear data.