I'm trying to create a gradient with Direct2D 1.1.
Specifically, I'm trying to create an ID2D1GradientStopCollection1.
my code:
ID2D1GradientStopCollection1* native = nullptr;
hr = context2_->CreateGradientStopCollection(
(D2D1_GRADIENT_STOP*)gradientStops,
gradientStopsCount,
D2D1_COLOR_SPACE_SRGB,
D2D1_COLOR_SPACE_SRGB,
D2D1_BUFFER_PRECISION_UNKNOWN,
D2D1_EXTEND_MODE_CLAMP,
D2D1_COLOR_INTERPOLATION_MODE_STRAIGHT,
&native
);
// hr returns 0x8899000a : A call to this method is invalid.
Note: context2_ is of type: ID2D1DeviceContext*
Executing this statement fails. The error code returned in hr is 0x8899000a (A call to this method is invalid.)
Any help getting this to work appreciated.
This method requires a specific buffer precision.
hr = context2_->CreateGradientStopCollection(
(D2D1_GRADIENT_STOP*)gradientStops,
gradientStopsCount,
D2D1_COLOR_SPACE_SRGB,
D2D1_COLOR_SPACE_SRGB,
D2D1_BUFFER_PRECISION_8BPC_UNORM_SRGB, // Buffer precision
D2D1_EXTEND_MODE_CLAMP,
D2D1_COLOR_INTERPOLATION_MODE_STRAIGHT,
&native2);
User contributions licensed under CC BY-SA 3.0