在c++中使用CIMG设置行模式

setting the line pattern using CIMG for c++

本文关键字:设置 模式 CIMG c++      更新时间:2023-10-16

我正在尝试学习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. 

我的问题是模式,我没能在文档中找到哪个整数代表哪一种行。有人知道如何操作这个模式吗?

提前感谢

一位开发人员通过电子邮件回答了我这个问题,我把它贴在这里供任何有同样问题的人使用。

该模式由unsigned int型的位的设置方式给出。你必须把你的无符号整数看作一个32像素的模式。32位),可以是透明的(位设置为0)或不透明的(位设置为0)1)。例如,所有位都设置为1的模式是完全不透明的,并且对应模式值0xFFFFFFFF。其中8个像素是透明的,然后8个像素是不透明的对应模式0xFF00FF00。像0xCCCCCCCC这样的模式表示1像素透明,然后1像素不透明,等等…