How to output this 24 bit image in Qt

荒凉一梦 提交于 2019-12-01 01:41:15

You can create a QImage directly from a block of data without copying every pixel.

Since your image is stored with separate rows, you need something like

QImage image = new QImage(width,height,QImage::RGB888)

for (int h=0;h<height;h++) {
    // scanLine returns a ptr to the start of the data for that row
    memcpy(image.scanLine(h),chars[h],width*3);
}

if you use RGB32 then you need to manually set the alpha channel for each pixel to 0xff - just memset() the entire data to 0xff first

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!