c++ - Direct2d ID2D1GradientStopCollection1 - 如何创建
问题描述
我正在尝试使用 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);
推荐阅读
- python - 用 jupyter notebook 写的张量板不起作用
- angular - 当另一个模态关闭时如何打开一个角度2材料模态
- jmeter - Jmeter-仅在请求或断言失败时打印日志
- branching-and-merging - 如何设置动态 svn 分支 - 与正常策略的偏差
- django - 如何从请求用户创建动态模型
- python - 如何从 HTML 文件中删除 Python 中的 HTML 标记?
- php - Joomla 3.8 与 PHP 7 问题
- scala - 如何在迭代中发出定期结果?
- mongodb - MongoDB 找到文档但相同的更新查询更新了 0 条记录
- angular - 如何在模块之间共享自定义验证器