OSDN Git Service

drop support for PGM
authorIvailo Monev <xakepa10@gmail.com>
Fri, 17 Dec 2021 09:31:05 +0000 (11:31 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Fri, 17 Dec 2021 09:31:05 +0000 (11:31 +0200)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
README
src/gui/image/qimagereader.cpp
src/gui/image/qimagewriter.cpp
src/gui/image/qppmhandler.cpp
tests/benchmarks/gui/image/qimagereader/images/image.pgm [deleted file]

diff --git a/README b/README
index abe653c..0cbe7be 100644 (file)
--- a/README
+++ b/README
@@ -39,7 +39,7 @@ There are several things you should be aware before considering Katie:
   - dropped Motif Drag-And-Drop (DND) support
   - dropped LPR support
   - dropped static plugins support
-  - dropped XBM, MNG, BMP, ICO, TGA, JPEG, TIFF and GIF image format support
+  - dropped XBM, PGM, MNG, BMP, ICO, TGA, JPEG, TIFF and GIF image format support
   - dropped obscure (24-bit) image formats support
   - dropped Valgrind support
   - dropped recursive mutex and lock support
index e1f576d..f89b0ee 100644 (file)
@@ -138,8 +138,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
         handler = new QXpmHandler;
 #endif
 #ifndef QT_NO_IMAGEFORMAT_PPM
-    } else if (form == "pbm" || form == "pbmraw" || form == "pgm"
-        || form == "pgmraw" || form == "ppm" || form == "ppmraw") {
+    } else if (form == "pbm" || form == "pbmraw" || form == "ppm" || form == "ppmraw") {
         handler = new QPpmHandler;
         handler->setOption(QImageIOHandler::SubType, form);
 #endif
@@ -1057,7 +1056,6 @@ QByteArray QImageReader::imageFormat(QIODevice *device)
     \header \o Format \o Description
     \row    \o PNG    \o Portable Network Graphics
     \row    \o PBM    \o Portable Bitmap
-    \row    \o PGM    \o Portable Graymap
     \row    \o PPM    \o Portable Pixmap
     \row    \o XPM    \o X11 Pixmap
     \row    \o SVG    \o Scalable Vector Graphics
@@ -1076,7 +1074,7 @@ QList<QByteArray> QImageReader::supportedImageFormats()
     QList<QByteArray> formats = QList<QByteArray>()
         << "png"
 #ifndef QT_NO_IMAGEFORMAT_PPM
-        << "ppm" << "pgm" << "pbm"
+        << "ppm" << "pbm"
 #endif
 #ifndef QT_NO_IMAGEFORMAT_XPM
         << "xpm"
index adb41c5..acc2820 100644 (file)
@@ -107,8 +107,7 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device,
         handler = new QXpmHandler;
 #endif
 #ifndef QT_NO_IMAGEFORMAT_PPM
-    } else if (form == "pbm" || form == "pbmraw" || form == "pgm"
-        || form == "pgmraw" || form == "ppm" || form == "ppmraw") {
+    } else if (form == "pbm" || form == "pbmraw" || form == "ppm" || form == "ppmraw") {
         handler = new QPpmHandler;
         handler->setOption(QImageIOHandler::SubType, form);
 #endif
index e5b0bf6..52066c8 100644 (file)
@@ -34,7 +34,7 @@
 QT_BEGIN_NAMESPACE
 
 /*****************************************************************************
-  PBM/PGM/PPM (ASCII and RAW) image read/write functions
+  PBM/PPM (ASCII and RAW) image read/write functions
  *****************************************************************************/
 
 static int read_pbm_int(QIODevice *d)
@@ -110,11 +110,6 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q
             nbits = 1;
             format = QImage::Format_Mono;
             break;
-        case '2':                                // ascii PGM
-        case '5':                                // raw PGM
-            nbits = 8;
-            format = QImage::Format_Indexed8;
-            break;
         case '3':                                // ascii PPM
         case '6':                                // raw PPM
             nbits = 32;
@@ -240,7 +235,6 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy
     QByteArray format = sourceFormat;
 
     format = format.left(3);                        // ignore RAW part
-    bool gray = format == "pgm";
 
     if (format == "pbm") {
         image = image.convertToFormat(QImage::Format_Mono);
@@ -286,29 +280,22 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy
         }
 
         case 8: {
-            str.insert(1, gray ? '5' : '6');
+            str.insert(1, '6');
             str.append("255\n");
             if (out->write(str, str.length()) != str.length())
                 return false;
             QVector<QRgb> color = image.colorTable();
-            uint bpl = w*(gray ? 1 : 3);
+            uint bpl = w*3;
             QSTACKARRAY(uchar, buf, bpl);
             for (uint y=0; y<h; y++) {
                 uchar *b = image.scanLine(y);
                 uchar *p = buf;
                 uchar *end = buf+bpl;
-                if (gray) {
-                    while (p < end) {
-                        uchar g = (uchar)qGray(color[*b++]);
-                        *p++ = g;
-                    }
-                } else {
-                    while (p < end) {
-                        QRgb rgb = color[*b++];
-                        *p++ = qRed(rgb);
-                        *p++ = qGreen(rgb);
-                        *p++ = qBlue(rgb);
-                    }
+                while (p < end) {
+                    QRgb rgb = color[*b++];
+                    *p++ = qRed(rgb);
+                    *p++ = qGreen(rgb);
+                    *p++ = qBlue(rgb);
                 }
                 if (bpl != (uint)out->write((char*)buf, bpl))
                     return false;
@@ -317,28 +304,21 @@ static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, const QBy
         }
 
         case 32: {
-            str.insert(1, gray ? '5' : '6');
+            str.insert(1, '6');
             str.append("255\n");
             if (out->write(str, str.length()) != str.length())
                 return false;
-            uint bpl = w*(gray ? 1 : 3);
+            uint bpl = w*3;
             QSTACKARRAY(uchar, buf, bpl);
             for (uint y=0; y<h; y++) {
                 QRgb  *b = (QRgb*)image.scanLine(y);
                 uchar *p = buf;
                 uchar *end = buf+bpl;
-                if (gray) {
-                    while (p < end) {
-                        uchar g = (uchar)qGray(*b++);
-                        *p++ = g;
-                    }
-                } else {
-                    while (p < end) {
-                        QRgb rgb = *b++;
-                        *p++ = qRed(rgb);
-                        *p++ = qGreen(rgb);
-                        *p++ = qBlue(rgb);
-                    }
+                while (p < end) {
+                    QRgb rgb = *b++;
+                    *p++ = qRed(rgb);
+                    *p++ = qGreen(rgb);
+                    *p++ = qBlue(rgb);
                 }
                 if (bpl != (uint)out->write((char*)buf, bpl))
                     return false;
@@ -397,9 +377,6 @@ bool QPpmHandler::canRead(QIODevice *device, QByteArray *subType)
     if (head[1] == '1' || head[1] == '4') {
         if (subType)
             *subType = "pbm";
-    } else if (head[1] == '2' || head[1] == '5') {
-        if (subType)
-            *subType = "pgm";
     } else if (head[1] == '3' || head[1] == '6') {
         if (subType)
             *subType = "ppm";
@@ -459,11 +436,7 @@ QVariant QPpmHandler::option(ImageOption option) const
         switch (type) {
             case '1':                                // ascii PBM
             case '4':                                // raw PBM
-            format = QImage::Format_Mono;
-            break;
-            case '2':                                // ascii PGM
-            case '5':                                // raw PGM
-                format = QImage::Format_Indexed8;
+                format = QImage::Format_Mono;
                 break;
             case '3':                                // ascii PPM
             case '6':                                // raw PPM
diff --git a/tests/benchmarks/gui/image/qimagereader/images/image.pgm b/tests/benchmarks/gui/image/qimagereader/images/image.pgm
deleted file mode 100644 (file)
index 443bf40..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-P2
-24 7
-15
-0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
-0  3  3  3  3  0  0  7  7  7  7  0  0 11 11 11 11  0  0 15 15 15 15  0
-0  3  0  0  0  0  0  7  0  0  0  0  0 11  0  0  0  0  0 15  0  0 15  0
-0  3  3  3  0  0  0  7  7  7  0  0  0 11 11 11  0  0  0 15 15 15 15  0
-0  3  0  0  0  0  0  7  0  0  0  0  0 11  0  0  0  0  0 15  0  0  0  0
-0  3  0  0  0  0  0  7  7  7  7  0  0 11 11 11 11  0  0 15  0  0  0  0
-0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0