GdipSetImageAttributesNoOpfunction
Turns off color adjustment for a specified category.
Syntax
FUNCTION GdipSetImageAttributesNoOp (BYVAL imageattr AS GpImageAttributes PTR, BYVAL type AS ColorAdjustType, BYVAL enableFlag AS BOOL) 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 color correction is turned off. The default value is ColorAdjustTypeDefault. | |
enableFlag | [in] Boolean value that specifies whether a color adjustment is enabled for the category specified by the type parameter. |
Description
Turns off color adjustment for a specified category.
Example
' ======================================================================================== ' This example applies a grayscale matrix, then disables it using GdipSetImageAttributesNoOp. ' ======================================================================================== SUB Example_SetNoOp (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 image DIM image AS GpImage PTR GdipLoadImageFromFile("climber.jpg", @image)
' Get image dimensions DIM nWidth AS UINT DIM nHeight AS UINT GdipGetImageWidth(image, @nWidth) GdipGetImageHeight(image, @nHeight)
' Create ImageAttributes DIM imgAttr AS GpImageAttributes PTR GdipCreateImageAttributes(@imgAttr)
' Define grayscale matrix DIM grayMatrix AS ColorMatrix grayMatrix.m(0,0) = 0.3 : grayMatrix.m(0,1) = 0.3 : grayMatrix.m(0,2) = 0.3 grayMatrix.m(1,0) = 0.59: grayMatrix.m(1,1) = 0.59: grayMatrix.m(1,2) = 0.59 grayMatrix.m(2,0) = 0.11: grayMatrix.m(2,1) = 0.11: grayMatrix.m(2,2) = 0.11 grayMatrix.m(3,3) = 1 grayMatrix.m(4,4) = 1
' Apply grayscale matrix GdipSetImageAttributesColorMatrix(imgAttr, ColorAdjustTypeBitmap, TRUE, @grayMatrix, NULL, ColorMatrixFlagsDefault)
' Draw grayscale image GdipDrawImageRectRect(graphics, image, 10, 10, nWidth, nHeight, 0, 0, nWidth, nHeight, UnitPixel, imgAttr, NULL, NULL)
' Disable color adjustments using GdipSetImageAttributesNoOp GdipSetImageAttributesNoOp(imgAttr, ColorAdjustTypeBitmap, TRUE)
' Draw original image (no color matrix applied) GdipDrawImageRectRect(graphics, image, 210, 10, nWidth, nHeight, 0, 0, nWidth, nHeight, UnitPixel, imgAttr, NULL, NULL)
' Cleanup GdipDisposeImage(image) GdipDeleteGraphics(graphics) GdipDisposeImageAttributes(imgAttr)
END SUB ' ========================================================================================
Reference
- Defined in AfxNova/AfxGdiPlus.bi:2139
- Documented in Graphics/GdiPlus Flat Api/GdiPlusImageAttributes.md
- Topic: ImageAttributes Functions