c++ - 使用 CIMG for c++ 设置线条图案

标签 c++ cimg

我正在努力学习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/

相关文章:

c++ - C++中的继承

C++/多态性/虚函数/为什么我的子类的函数没有被调用?

c++ - 为特定操作系统编写代码时,标准库调用与所有操作系统 API 调用之间的权衡是什么?

c++ - 使用 cimg C++ 进行图像处理

c++ - 使用 CLion 和 CMake 的 CImg X11 链接错误

c++ - CImg: 无法识别 jpg 格式

c++ - 有谁知道我是否可以使用 CImg 和 C++ 在图像窗口上绘图?

c++ - 对象数组参数-错误: field ‘letters’ has incomplete type

C++ 从文件中读取整数和字符串

c++ - 如何使用 CImg 库打开 PNG 而不丢失 alpha channel ?