diff --git a/src/plugins/imageformats/jpeg/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp index 6472702fddb..4e59ccb534c 100644 --- a/src/plugins/imageformats/jpeg/qjpeghandler.cpp +++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp @@ -532,6 +532,7 @@ static bool do_write_jpeg_image(struct jpeg_compress_struct &cinfo, cinfo.in_color_space = gray ? JCS_GRAYSCALE : JCS_RGB; break; case QImage::Format_Grayscale8: + case QImage::Format_Grayscale16: gray = true; cinfo.input_components = 1; cinfo.in_color_space = JCS_GRAYSCALE; @@ -630,6 +631,12 @@ static bool do_write_jpeg_image(struct jpeg_compress_struct &cinfo, case QImage::Format_Grayscale8: memcpy(row, image.constScanLine(cinfo.next_scanline), w); break; + case QImage::Format_Grayscale16: + { + QImage rowImg = image.copy(0, cinfo.next_scanline, w, 1).convertToFormat(QImage::Format_Grayscale8); + memcpy(row, rowImg.constScanLine(0), w); + } + break; case QImage::Format_RGB888: memcpy(row, image.constScanLine(cinfo.next_scanline), w * 3); break;