GdipSetImageAttributesGammafunction
Sets the gamma value for a specified category.
Syntax
FUNCTION GdipSetImageAttributesGamma (BYVAL imageattr AS GpImageAttributes PTR, BYVAL type AS ColorAdjustType, BYVAL enableFlag AS BOOL, BYVAL gamma AS REAL) AS GpStatus
Parameters
| Name | Description | |
|---|---|---|
imageattr | [in] Pointer to the ImageAttributes object. | |
type | [in] Element of the ColorAdjustType enumeration that specifies the category for which the gamma value is set. The default value is ColorAdjustTypeDefault. | |
enableFlag | [in] Boolean value that specifies whether a separate gamma is enabled for the category specified by the type parameter. | |
gamma | [in] Single precision value number that specifies the gamma value. |
Description
Sets the gamma value for a specified category.
Example
' ======================================================================================== ' This example applies gamma correction to an image using GdipSetImageAttributesGamma. ' ======================================================================================== SUB Example_SetGamma (BYVAL hdc AS HDC)
DIM hStatus AS LONG
' // Create a graphics object from the device context DIM graphics AS GpGraphics PTR hStatus = GdipCreateFromHDC(hdc, @graphics)
' // Get the DPI scaling ratios DIM dpiX AS SINGLE hStatus = GdipGetDpiX(graphics, @dpiX) DIM rxRatio AS SINGLE = dpiX / 96 DIM dpiY AS SINGLE hStatus = GdipGetDpiY(graphics, @dpiY) Dim ryRatio AS SINGLE = dpiY / 96 ' // Set the scale transform hStatus = GdipScaleWorldTransform(graphics, rxRatio, ryRatio, MatrixOrderPrepend)
' // Load an image from file DIM image AS GpImage PTR hStatus = GdipLoadImageFromFile("climber.jpg", @image) ' // Set the resolution of this image object to the user's DPI settings hStatus = GdipBitmapSetResolution(image, dpiX, dpiY)
' // Get the width and height of the image DIM AS LONG nWidth, nHeight hStatus = GdipGetImageWidth(image, @nWidth) hStatus = GdipGetImageHeight(image, @nHeight)
' // Create an ImageAttributes object DIM imgAttr AS GpImageAttributes PTR hStatus = GdipCreateImageAttributes(@imgAttr)
' // Apply gamma correction (e.g., 2.2) hStatus = GdipSetImageAttributesGamma(imgAttr, ColorAdjustTypeDefault, TRUE, 2.2)
' // Draw original image hStatus = GdipDrawImageRect(graphics, image, 10, 10, nWidth, nHeight)
' // Draw gamma-adjusted image hStatus = GdipDrawImageRectRect(graphics, image, _
200, 10, nWidth, nHeight, _
0, 0, nWidth, nHeight, _
UnitPixel, imgAttr, NULL, NULL)
' // Cleanup IF imgAttr THEN GdipDisposeImageAttributes(imgAttr) IF image THEN GdipDisposeImage(image) IF graphics THEN GdipDeleteGraphics(graphics)
END SUB ' ========================================================================================
Reference
- Defined in AfxNova/AfxGdiPlus.bi:2137
- Documented in Graphics/GdiPlus Flat Api/GdiPlusImageAttributes.md
- Topic: ImageAttributes Functions