QT之RAW转jpg

来源:互联网 发布:魔域副本源码 编辑:程序博客网 时间:2024/06/06 03:36
void MainWindow::rawtojpg(){    QFile raw("C:\\Users\\Administrator\\Desktop\\avi\\00000000_009.raw");    if  (!raw.open(QIODevice::ReadWrite))        return;    char *pDate = new char[CMOS_INPUT_WIDTH*CMOS_INPUT_HEIGHT];    raw.read(pDate,CMOS_INPUT_WIDTH*CMOS_INPUT_HEIGHT);    quint32 *pRgb = new quint32[CMOS_INPUT_WIDTH * CMOS_INPUT_HEIGHT];    //convert gray image to rgb;    for (int h = 0; h < CMOS_INPUT_HEIGHT; h++){        for (int row = 0; row < CMOS_INPUT_WIDTH; row++) {            quint32 gray = (int)pDate[CMOS_INPUT_WIDTH * h + row];            quint32 argb32 =  gray << 16 | gray << 8 | gray | 0xff000000;            pRgb[CMOS_INPUT_WIDTH * h + row] = argb32;        }    }    QImage grayImage((uchar *)pRgb,CMOS_INPUT_WIDTH,CMOS_INPUT_HEIGHT,QImage::Format_RGB32);    QImage newimage = grayImage.scaled (ui->image_label->width (),ui->image_label->height ());    ui->image_label->setPixmap(QPixmap::fromImage(newimage));    QImage image;    //image.load ("C:\\Users\\Administrator\\Desktop\\image\\7.jpg");    pupiltwoValued(&grayImage, &grayImage);    //grayImage.save("C:\\Users\\Administrator\\Desktop\\grayTest.jpg");    delete pDate;    delete pRgb;}

原创粉丝点击