Help Center

GdipSetImageAttributesOutputChannelfunction

Sets the CMYK output channel for a specified category.

Graphicsfunctiondocumented

Syntax

FUNCTION GdipSetImageAttributesOutputChannel (BYVAL imageattr AS GpImageAttributes PTR, BYVAL type AS ColorAdjustType, BYVAL enableFlag AS BOOL, BYVAL channelFlags AS ColorChannelFlags) AS GpStatus

Parameters

NameDescription
imageattr[in] Pointer to the ImageAttributes object.
type[in] Element of the ColorAdjustType enumeration that specifies the category for which the output channel is set. The default value is ColorAdjustTypeDefault.
enableFlag[in] Boolean value that specifies whether a separate output channel is enabled for the category specified by the type parameter.
channelFlags[in] Element of the ColorChannelFlags enumeration that specifies the output channel.

Description

Sets the CMYK output channel for a specified category.

Example

' ======================================================================================== ' The following example creates an Image object and calls the GdipDrawImageRect function ' to draw the image. Then the code creates an ImageAttributes object and sets its bitmap ' output channel to cyan (ColorChannelFlagsC). The code calls GdipDrawImageRect a second ' time, passing the address of the Image object and the address of the ImageAttributes object. ' The cyan channel of each pixel is calculated, and the rendered image shows the intensities ' of the cyan channel as shades of gray. The code calls GdipDrawImageRect three more times ' to show the intensities of the magenta, yellow, and black channels. ' ======================================================================================== SUB Example_SetOutputChannel (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("Mosaic2.bmp", @image) ' // Set the resolution of this image object to the user's DPI settings hStatus = GdipBitmapSetResolution(image, dpiX, dpiY)

' // Draw the image unaltered. DIM AS LONG nWidth, nHeight hStatus = GdipGetImageWidth(image, @nWidth) hStatus = GdipGetImageHeight(image, @nHeight) hStatus = GdipDrawImageRect(graphics, image, 10, 10, nWidth, nHeight)

' // Create an ImageAttributes object DIM imgAttr AS GpImageAttributes PTR hStatus = GdipCreateImageAttributes(@imgAttr)

' // Draw the image, showing the intensity of the cyan channel. hStatus = GdipSetImageAttributesOutputChannel(imgAttr, ColorAdjustTypeBitmap, TRUE, ColorChannelFlagsC) hStatus = GdipDrawImageRectRect(graphics, image, _

110, 10, nWidth, nHeight, _   ' dest rect
         0, 0, nWidth, nHeight, _      ' source dest
         UnitPixel, imgAttr, NULL, NULL)

' // Draw the image, showing the intensity of the magenta channel. hStatus = GdipSetImageAttributesOutputChannel(imgAttr, ColorAdjustTypeBitmap, TRUE, ColorChannelFlagsM) hStatus = GdipDrawImageRectRect(graphics, image, _

210, 10, nWidth, nHeight, _   ' dest rect
         0, 0, nWidth, nHeight, _      ' source dest
         UnitPixel, imgAttr, NULL, NULL)

' // Draw the image, showing the intensity of the yellow channel. hStatus = GdipSetImageAttributesOutputChannel(imgAttr, ColorAdjustTypeBitmap, TRUE, ColorChannelFlagsY) hStatus = GdipDrawImageRectRect(graphics, image, _

10, 110, nWidth, nHeight, _   ' dest rect
         0, 0, nWidth, nHeight, _      ' source dest
         UnitPixel, imgAttr, NULL, NULL)

' // Draw the image, showing the intensity of the black channel. hStatus = GdipSetImageAttributesOutputChannel(imgAttr, ColorAdjustTypeBitmap, TRUE, ColorChannelFlagsK) hStatus = GdipDrawImageRectRect(graphics, image, _

110, 110, nWidth, nHeight, _  ' dest rect
         0, 0, nWidth, nHeight, _      ' source dest
         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:2142
  • Documented in Graphics/GdiPlus Flat Api/GdiPlusImageAttributes.md
  • Topic: ImageAttributes Functions