Simple code: cv::Mat left_image = cv::imread(filename, cv::IMREAD_COLOR ); cv::cvtColor(mat, mat, cv::COLOR_BGR2GRAY); cv::imwrite("dummy_gray_cv.png", left_image); // ok QImage test((unsigned char*) left_image.data, left_image.cols, left_image.rows, QImage::Format_Grayscale8); test.save("dummy_gray_qt.png"); // skewed
However the dummy_gray_qt.png image is not aligned correctly, it's skewed as if bytes are missing/being skipped. I have to convert it back to color to work: cv::Mat dst; cv::cvtColor(left_image, dst, cv::COLOR_GRAY2BGRA); QImage result = QImage((unsigned char*) dst.data, dst.cols, dst.rows, QImage::Format_RGB32); result.save("dummy_color_qt.png") Is there a way I can avoid needing cv::cvtColor(left_image, dst, cv::COLOR_GRAY2BGRA)? _______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest