CGpImageAttributes.SetOutputChannelColorProfilemethod
Sets the output channel color-profile file for a specified category.
Syntax
FUNCTION SetOutputChannelColorProfile (BYVAL pwszColorProfileFilename AS WSTRING PTR, BYVAL nType AS ColorAdjustType = ColorAdjustTypeDefault) AS GpStatus
Parameters
| Name | Description | |
|---|---|---|
pwszColorProfileFilename | Path name of a color-profile file. If the color-profile file is in the %SystemRoot%\System32\Spool\Drivers\Color directory, then this parameter can be the file name. Otherwise, this parameter must be the fully-qualified path name. | |
nType | Optional. Element of the ColorAdjustType enumeration that specifies the category for which the color key is cleared. The default value is ColorAdjustTypeDefault. |
Return value
If the function succeeds, it returns StatusOk, which is an element of the GpStatus enumeration.
If the function fails, it returns one of the other elements of the GpStatus enumeration.
Description
Sets the output channel color-profile file for a specified category.
Remarks
You can use the SetOutputChannel and SetOutputChannelColorProfile methods to convert an image to a cyan-magenta-yellow-black (CMYK) color space and examine the intensities of one of the CMYK color channels. For example, suppose you write code that performs the following steps:
- Create an Image object.
- Create an ImageAttributes object.
- Pass ColorChannelFlagsC to the SetOutputChannel method of the ImageAttributes object.
- Pass the path name of a color profile file to the SetOutputChannelColorProfile method of the ImageAttributes object.
- Pass the addresses of the Image and ImageAttributes objects to the DrawImage method.
Windows GDI+ will use the color-profile file to calculate the cyan component of each pixel in the image, and each pixel in the rendered image will be a shade of gray that indicates the intensity of its cyan channel.
An ImageAttributes object maintains color and grayscale settings for five adjustment categories: default, bitmap, brush, pen, and text. For example, you can specify an output channel color-profile file for the default category and a different output channel color-profile file for the bitmap category.
The default color- and grayscale-adjustment settings apply to all categories that don't have adjustment settings of their own. For example, if you never specify any adjustment settings for the bitmap category, then the default settings apply to the bitmap category.
As soon as you specify a color- or grayscale-adjustment setting for a certain category, the default adjustment settings no longer apply to that category. For example, suppose you specify a collection of adjustment settings for the default category. If you set the output channel color-profile file for the bitmap category by passing ColorAdjustTypeBitmap to the SetOutputChannelColorProfile method, then none of the default adjustment settings will apply to bitmaps.
Flat API function: GdipSetImageAttributesOutputChannelColorProfile.
Example
' ======================================================================================== ' This example sets a CMYK output channel color profile using SetOutputChannelColorProfile. ' ======================================================================================== SUB Example_SetOutputChannelColorProfile (BYVAL hdc AS HDC)
' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scaling factors using the DPI ratios graphics.ScaleTransformForDpi
' // Create an Image object based on a .bmp file. ' // The image has one stripe with RGB components (160, 0, 0) ' // and one stripe with RGB components (0, 140, 0). DIM image AS CGpBitmap = "climber.jpg" image.SetResolutionForDpi
' // Draw the image unaltered. DIM nWidth AS UINT = image.GetWidth DIM nHeight AS UINT = image.GetHeight graphics.DrawImage(@image, 10, 10, nWidth, nHeight)
' // Create an ImageAttributes object, and set its bitmap threshold to 0.6. DIM imgAttr AS CGpImageAttributes
' // Set CMYK color profile (must be a valid ICC file path) DIM colorProfileFilename AS WSTRING * MAX_PATH = "C:\Program Files\Bullzip\PDF Printer\icc\sRGB_IEC61966-2-1_no_black_scaling.icc" imgAttr.SetOutputChannelColorProfile(colorProfileFilename)
' // Draw image with color profile applied DIM rc AS GpRect = (10, 10, nWidth, nHeight) graphics.DrawImage(@image, @rc, 0, 0, nWidth, nHeight, UnitPixel, @imgAttr)
END SUB ' ========================================================================================
Reference
- Include file
CGpImageAttributes.inc - Defined in AfxNova/CGpImageAttributes.inc:184
- Documented in Graphics/GdiPlus Classes/CGpImage Classes.md
- Topic: CGpImage Class