无法输出对象的红色/绿色/蓝色值
Cannot output red/green/blue color value of object
vector<Text> Game_Text;
Game_Text.push_back(Text("0",Game_Font[0],50));
cout<<Game_Text[0].getFillColor().r<<endl;
在代码中使用 C++11::块
运行时没有输出任何东西,它不应该输出 255 吗?如果Game_Text[0].getFillColor().r
被替换为,比如说,"test"
,它会正常输出test
。没有错误,完整的代码正在工作。
使用此方法是否可以仅输出对象的单个 r/g/b 值?
Color
成员r
的类型为Uint8
,这是unsigned char
的别名。
char
(以及signed char
和unsigned char
,以及基于这些类型的所有别名(由输出运算符<<
作为字符处理。
因此
cout<<Game_Text[0].getFillColor().r<<endl;
将尝试将r
打印为字符。如果其值与可打印字符不对应,则似乎不会打印任何内容。
要打印整数值,您需要将其转换为不基于char
的整数类型:
cout << static_cast<unsigned>(Game_Text[0].getFillColor().r) << 'n';
相关文章:
- 无法输出对象的红色/绿色/蓝色值
- 如何使用 opencv 绘制绿色矩形?
- 如何通过组合红色和蓝色无符号字节来优化混合?
- WICConvertBitmapSource + CopyPixel结果为蓝色图像
- 创建一个绿色三角形C Directx
- 用SDL2和OpenGL显示蓝色
- OPENCV:从RGB转换为灰度只有蓝色
- 默认构造的地图迭代器以增量进入无限环路 - 绿色山丘编译器
- 想要从图像获取绿色 RGB 通道时出错
- 在虚幻引擎中C 和蓝色印刷之间的接口
- 如何在qt中显示闪烁的[动画]红色/绿色状态图标
- 使用OpenCV的c++中图像的绿色分量的直方图
- GLSL 将纹理渲染为黑色和蓝色
- Alpha 通道在 directx11 和 c++ 中起作用并输出绿色
- 在本机 Win32 GDI 中绘制略微透明的蓝色矩形
- 缺少使用glTexImage2D功能的绿色组件,为什么
- 消息在VC++的模式框中以蓝色突出显示
- 如果新图像中的原始像素为黑色,则Qt绘制一个蓝色像素
- Win32应用程序正在获取要更改为完全蓝色、红色或绿色的像素
- 用于c++的Colormap库,它将给定的值转换为红色,绿色和蓝色值