QImage image(reinterpret_cast<unsigned char*>(imageSrc->data()), params.pixels_per_line, params.lines, params.bytes_per_line, QImage::Format_Indexed8); QVector<QRgb> colors; for(int i = 0; i < 255; ++i) colors.append(qGray(i,i,i)); image.setColorTable(colors); image.save("testImage.tiff");