我正在努力学习Cimg但有时文档非常模糊。 我正在使用绘图功能,我想画一条线。函数声明非常简单:
CImg<T>& draw_line ( const int x0,
const int y0,
const int x1,
const int y1,
const tc *const color,
const float opacity = 1,
const unsigned int pattern = ~0U,
const bool init_hatch = true
)
哪里
x0 X-coordinate of the starting line point.
y0 Y-coordinate of the starting line point.
x1 X-coordinate of the ending line point.
y1 Y-coordinate of the ending line point.
color Pointer to spectrum() consecutive values of type T, defining the drawing color.
opacity Drawing opacity.
**pattern An integer whose bits describe the line pattern.**
init_hatch Tells if a reinitialization of the hash state must be done.
我的问题是模式,我无法在文档中找到哪些整数代表哪种线。现在有人知道如何操纵该模式吗?
提前谢谢
最佳答案
其中一位开发人员通过电子邮件回复了我这个问题,我将其发布在这里供有相同问题的任何人使用。
The pattern is given by how the bits in the unsigned int are sets. You have to look at your unsigned integer as a pattern of 32 pixels (i.e. 32bits) that can be either transparent (bit set to 0) or opaque (bit set to 1). For instance, a pattern where all bits are set to 1 is full opaque, and corresponds to pattern value 0xFFFFFFFF. A pattern where 8 pixels are transparent, then 8 pixels are opaque corresponds to pattern 0xFF00FF00. A pattern like 0xCCCCCCCC means 1 pixel transparent, then 1 pixel opaque, etc...
关于c++ - 使用 CIMG for c++ 设置线条图案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39604782/