赞
踩
在图像处理时,我们经常会取图像的rgb,然后把rgb转为yuv 再h264编码
qt中图像处理一般是qimage,我们可以把普通的一张图片,提取出rgb
首先,可以用QLabel 显示图像
定义一个:QLabel *imageview;
定义一个:QImage image
- QPixmap pixmap = QPixmap::fromImage(image); //从QImage中获取像素map
- //QPixmap fitpixmap = pixmap.scaled(with, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); // 饱满填充
- QPixmap fitpixmap = pixmap.scaled(with, height, Qt::KeepAspectRatio, Qt::SmoothTransformation); // 按比例缩放
- ui->imageview->setPixmap(fitpixmap); //显示在label上
取rgb
- //定义一个char指针存放rgb字节流,长度为图像的宽*高*3(r,g,b) 3个字节,rgb24
- unsigned char *rgbbuf = (unsigned char *)malloc(w*h * 3);
- //yuv 宽*高*3/2 y,u,v
- unsigned char *yuvbuf = (unsigned char *)malloc(w*h * 1.5);
- ///获取rbg
- for (int row = 0; row < h; ++row)
- for (int col = 0; co
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。