Qt中如何用QImage::Format_Indexed8表示灰度图
2014-09-01 08:49
190 查看
QImage *qi = new QImage(data_ptr, width, height, QImage::Format_Indexed8); QVector<QRgb> grayTable; for(int i = 0; i < 256; i++) graytable.push_back(qRgb(i,i,i)); qi->setColorTable(grayTable);
qt中仅有按照索引的8位位图,需要添加ColorTable,QImage中定义ColorTable的原型如下:
void QImage::setColorTable(constQVector<QRgb>
colors)
Sets the color table used to translate color indexes toQRgb values, to the specified colors.
When the image is used, the color table must be large enough to have entries for all the pixel/index values present in the image, otherwise the results are undefined.
因为灰度值分别对应rgb相同的分布,因此取vector0-255对应为qRGB(i,i,i) i在0-255之间。
相关文章推荐
- Qt中如何用QImage::Format_Indexed8表示灰度图
- 【Qt开发】QImage设置为8-bit灰度图
- [导入]终于找到 SourceFormatX 2.56 的完美注册破解版及如何破解详细方法了
- 如何在DataGrid里面使用动态图形表示数字
- 如何将真彩色图转换为各种灰度图
- cpp中如何表示无穷大
- 如何计算和表示需求稳定度
- 如何在minicom下运行可键盘中断结束的qt-embedded程序
- 如何将真彩色图转换为各种灰度图
- 如何获取错误消息说明使用 FormatMessage API
- ListItem[] 类型如何在 VB.net中表示
- [导入]如何在DataGrid里面使用动态图形表示数字
- 如何对MFC的CString::Format的封装
- [WPF]WPF中如何实现数据与表示分离。(一) —— XAML
- [WPF]WPF中如何实现数据与表示分离。(二) —— Binding(下)
- 如何在unix下编译QT程序?
- 如何用正则表达式来表示中文?
- 请问如何用四个字节的十六进制表示一个float浮点数
- 如何将一个包含颜色信息的长整类型转化为 RGB 表示
- Eval("string", string format) 如何输出格式转换??