The following example creates a solid brush based on a color that has an alpha component of 128. The code uses that brush to paint two rectangles. The first rectangle is painted with the compositing mode set to
CompositingQualityHighSpeed, and the second rectangle is painted with the compositing mode set to
CompositingQualityHighQuality.
C++
VOID Example_SetCompositingQuality(HDC hdc)
{
Graphics graphics(hdc);
// Create a SolidBrush object with an alpha-blended color.
SolidBrush alphaBrush(Color(180, 255, 0, 0));
// Set the compositing mode to CompositingQualityHighSpeed,
// and fill a rectangle.
graphics.SetCompositingQuality(CompositingQualityHighSpeed);
graphics.FillRectangle(&alphaBrush, 0, 0, 100, 100);
// Set the compositing mode to CompositingQualityHighQuality,
// and fill a rectangle.
graphics.SetCompositingQuality(CompositingQualityHighQuality);
graphics.FillRectangle(&alphaBrush, 100, 0, 100, 100);
}
PowerBASIC
SUB GDIP_SetCompositingQuality (BYVAL hdc AS DWORD)
LOCAL hStatus AS LONG
LOCAL pGraphics AS DWORD
LOCAL pAlphaBrush AS DWORD
hStatus = GdipCreateFromHDC(hdc, pGraphics)
' // Create a SolidBrush object with an alpha-blended color.
hStatus = GdipCreateSolidFill(GDIP_ARGB(180, 255, 0, 0), pAlphaBrush)
' // Set the compositing mode to CompositingQualityHighSpeed, and fill a rectangle.
hStatus = GdipSetCompositingQuality(pGraphics, %CompositingQualityHighSpeed)
hStatus = GdipFillRectangle(pGraphics, pAlphaBrush, 0, 0, 100, 100)
' // Set the compositing mode to CompositingQualityHighQuality, and fill a rectangle.
hStatus = GdipSetCompositingMode(pGraphics, %CompositingQualityHighQuality)
hStatus = GdipFillRectangle(pGraphics, pAlphaBrush, 100, 0, 100, 100)
' // Cleanup
IF pAlphaBrush THEN GdipDeleteBrush(pAlphaBrush)
IF pGraphics THEN GdipDeleteGraphics(pGraphics)
END SUB
(http://www.jose.it-berater.org/captures/GdipSetCompositingQuality.png)