Help Center

GdipSetImageAttributesRemapTablefunction

Sets the color-remap table for a specified category.

Graphicsfunctiondocumented

Syntax

FUNCTION GdipSetImageAttributesRemapTable (BYVAL imageattr AS GpImageAttributes PTR, BYVAL type AS ColorAdjustType, BYVAL enableFlag AS BOOL, BYVAL mapSize AS UINT, BYVAL map AS GpColorMap) 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 color-remap table is set. The default value is ColorAdjustTypeDefault.
enableFlag[in] Boolean value that specifies whether a separate color remap table is enabled for the category specified by the type parameter.
mapSize[in] Long integer value that specifies the number of elements in the map array.
map[in] Pointer to an array of GpColorMap structures that defines the color map.

Description

Sets the color-remap table for a specified category.

Example

' ======================================================================================== ' The following example creates an Image object based on a .bmp file and then draws the image. ' The code creates an ImageAttributes object and sets its default remap table so that red ' is converted to blue. Then the code draws the image again using the color adjustment ' specified by the remap table. ' ======================================================================================== SUB Example_SetRemapTable (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)

' // Create an Image object based on a .bmp file. ' // The image has one red stripe and one green stripe. DIM image AS GpImage PTR hStatus = GdipLoadImageFromFile("RedGreenStripes.bmp", @image)

' // Create an ImageAttributes object and set its remap table. DIM cMap AS GpColorMap cMap.oldColor = ARGB_RED cMap.newColor = ARGB_BLUE DIM imgAttr AS GpImageAttributes PTR hStatus = GdipCreateImageAttributes(@imgAttr) hStatus = GdipSetImageAttributesRemapTable(imgAttr, ColorAdjustTypeDefault, TRUE, 1, @cMap)

' // Get the width and height of the image DIM AS LONG nWidth, nHeight hStatus = GdipGetImageWidth(image, @nWidth) hStatus = GdipGetImageHeight(image, @nHeight)

' // Draw the image with no color adjustment hStatus = GdipDrawImageRect(graphics, image, 10, 10, nWidth, nHeight)

' // Draw the image with red converted to blue. hStatus = GdipDrawImageRectRect(graphics, image, _

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