Help Center

CGpGraphics.SetCompositingModemethod

Sets the compositing mode of this **Graphics** object.

GraphicsmethodCGpGraphics.incdocumented

Syntax

FUNCTION SetCompositingMode (BYVAL nCompositingMode AS CompositingMode) AS GpStatus

Parameters

NameDescription
nCompositingModeElement of the CompositingMode enumeration that specifies the compositing mode.

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 compositing mode of this Graphics object.

Example

' ======================================================================================== ' The following example creates a Graphics object and sets its compositing mode to ' CompositingModeSourceCopy. The code creates a SolidBrush object based on a color with an ' alpha component of 128. The code passes the address of that brush to the Graphics.FillRectangle ' method of the Graphics object to fill a rectangle with a color that is not blended with ' the background color. The call to the Graphics::CompositingMode method of the Graphics ' object demonstrates how to obtain the compositing mode (which is already known in this ' case). The code determines whether the compositing mode is CompositingModeSourceCopy and ' if so, changes it to CompositingModeSourceOver. Then the code calls Graphics.FillRectangle ' a second time to fill a rectangle with a color that is a half-and-half blend of the brush ' color and the background color. ' ======================================================================================== SUB Example_CompositingMode (BYVAL hdc AS HDC)

' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale transform graphics.ScaleTransformForDpi

graphics.SetCompositingMode(CompositingModeSourceCopy) DIM alphaBrush AS CGpSolidBrush = GDIP_ARGB(128, 255, 0, 0) graphics.FillRectangle(@alphaBrush, 0, 0, 100, 100)

' // Get the compositing mode. DIM compMode AS CompositingMode compMode = graphics.GetCompositingMode

' // Change the compositing mode if it is CompositingModeSourceCopy. IF compMode = CompositingModeSourceCopy THEN

graphics.SetCompositingMode(CompositingModeSourceOver)

END IF

graphics.FillRectangle(@alphaBrush, 0, 100, 100, 100)

END SUB ' ========================================================================================

Reference

  • Include file CGpGraphics.inc
  • Defined in AfxNova/CGpGraphics.inc:145
  • Documented in Graphics/GdiPlus Classes/CGpGraphics Classes.md
  • Topic: CGpGraphics Class