GdipGetLinePresetBlendCountfunction
Gets the number of colors currently set to be interpolated for a linear gradient brush.
Syntax
FUNCTION GdipGetLinePresetBlendCount (BYVAL brush AS GpLineGradient PTR, BYVAL count AS INT_ PTR) AS GpStatus
Parameters
| Name | Description | |
|---|---|---|
brush | [in] Pointer to the LinearGradientBrush object. | |
count | [out] Pointer to a variable that receives the number of colors to be interpolated for a linear gradient brush. If no colors have been set by using GdipSetLinePresetBlend, or if invalid positions were passed to GdipSetLinePresetBlend, then GdipGetLinePresetBlendCount returns 0. |
Description
Gets the number of colors currently set to be interpolated for a linear gradient brush.
Example
' ======================================================================================== ' This example sets a preset blend and then retrieves how many blend colors are active. ' You can use the count value to allocate arrays for GdipGetLinePresetBlend. ' ======================================================================================== SUB Example_GetLinePresetBlendCount (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 a linear gradient brush DIM rcf AS GpRectF = (0, 0, 200, 100) DIM brush AS GpLineGradient PTR GdipCreateLineBrushFromRect(@rcf, ARGB_WHITE, ARGB_BLACK, LinearGradientModeHorizontal, WrapModeTile, @brush)
' // Set preset blend DIM colors(2) AS ARGB = {ARGB_RED, ARGB_GREEN, ARGB_BLUE} DIM positions(2) AS SINGLE = {0.0, 0.5, 1.0} GdipSetLinePresetBlend(brush, @colors(0), @positions(0), 3)
' // Retrieve blend count DIM count AS LONG GdipGetLinePresetBlendCount(brush, @count)
' (Optional) Use count for logic or display ' For demonstration, fill rectangle GdipFillRectangle(graphics, brush, rcf.x, rcf.y, rcf.Width, rcf.Height)
' // Cleanup IF brush THEN GdipDeleteBrush(brush) IF graphics THEN GdipDeleteGraphics(graphics)
END SUB ' ========================================================================================
Reference
- Defined in AfxNova/AfxGdiPlus.bi:2178
- Documented in Graphics/GdiPlus Flat Api/GdiPlusLinearGradientBrush.md
- Topic: GdiPlusLinearGradientBrush