YUV420只绘制Y通道

前段时间整个一个yuv文件,格式为352x240,YUV420格式的,即YYYYUUVV,准备使用Qt进行重绘显示。不知道为什么转换为RGB显示出来乱乱的,

最近做只显示出Y通道的灰度图像,刚做成功。

灰度图像即RGB三颜色是一样的,需要建立一个8位的256级的灰度索引表,用0~255表示颜色的深度。

然后构建一个8位的QImage并设置它的颜色索引表,让它去颜色表中查颜色。

Qt中的QImage提供了对每一个像素的操作。

关键是setPixel这个函数。


void QImage::setPixel(const QPoint & position, uint index_or_rgb)
Sets the pixel index or color at the given position to index_or_rgb.

If the image's format is either monochrome or 8-bit, the given index_or_rgb value must be an index in the image's color table, otherwise the parameter must be a QRgb value.

If position is not a valid coordinate pair in the image, or if index_or_rgb >= colorCount() in the case of monochrome and 8-bit images, the result is undefined.

Warning: This function is expensive due to the call of the internal d

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值