我正在尝试使用Direct2D 1.1创建渐变。
具体来说,我正在尝试创建一个ID2D1GradientStopCollection1。
我的代码:
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.
注意:context2_的类型为:ID2D1DeviceContext *
执行此语句失败。 hr中返回的错误代码是0x8899000a(对此方法的调用无效。)
任何帮助让这个工作得到赞赏。
此方法需要特定的缓冲区精度。
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);