You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2019/10/12 18:52:09 UTC

svn commit: r1868373 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PNGConverter.java

Author: tilman
Date: Sat Oct 12 18:52:09 2019
New Revision: 1868373

URL: http://svn.apache.org/viewvc?rev=1868373&view=rev
Log:
PDFBOX-4341: SonarQube fix

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PNGConverter.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PNGConverter.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PNGConverter.java?rev=1868373&r1=1868372&r2=1868373&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PNGConverter.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/PNGConverter.java Sat Oct 12 18:52:09 2019
@@ -63,6 +63,34 @@ final class PNGConverter
 {
     private static final Log LOG = LogFactory.getLog(PNGConverter.class);
 
+    // Chunk Type definitions. The bytes in the comments are the bytes in the spec.
+    private static final int CHUNK_IHDR = 0x49484452; // IHDR: 73 72 68 82
+    private static final int CHUNK_IDAT = 0x49444154; // IDAT: 73 68 65 84
+    private static final int CHUNK_PLTE = 0x504C5445; // PLTE: 80 76 84 69
+    private static final int CHUNK_IEND = 0x49454E44; // IEND: 73 69 78 68
+    private static final int CHUNK_TRNS = 0x74524E53; // tRNS: 116 82 78 83
+    private static final int CHUNK_CHRM = 0x6348524D; // cHRM: 99 72 82 77
+    private static final int CHUNK_GAMA = 0x67414D41; // gAMA: 103 65 77 65
+    private static final int CHUNK_ICCP = 0x69434350; // iCCP: 105 67 67 80
+    private static final int CHUNK_SBIT = 0x73424954; // sBIT: 115 66 73 84
+    private static final int CHUNK_SRGB = 0x73524742; // sRGB: 115 82 71 66
+    private static final int CHUNK_TEXT = 0x74455874; // tEXt: 116 69 88 116
+    private static final int CHUNK_ZTXT = 0x7A545874; // zTXt: 122 84 88 116
+    private static final int CHUNK_ITXT = 0x69545874; // iTXt: 105 84 88 116
+    private static final int CHUNK_KBKG = 0x6B424B47; // kBKG: 107 66 75 71
+    private static final int CHUNK_HIST = 0x68495354; // hIST: 104 73 83 84
+    private static final int CHUNK_PHYS = 0x70485973; // pHYs: 112 72 89 115
+    private static final int CHUNK_SPLT = 0x73504C54; // sPLT: 115 80 76 84
+    private static final int CHUNK_TIME = 0x74494D45; // tIME: 116 73 77 69
+
+    /* Table of CRCs of all 8-bit messages. */
+    private static final int[] CRC_TABLE = new int[256];
+
+    static
+    {
+        makeCrcTable();
+    }
+
     private PNGConverter()
     {
     }
@@ -594,7 +622,7 @@ final class PNGConverter
         }
 
         // Check the IDATs
-        if (state.IDATs.size() == 0)
+        if (state.IDATs.isEmpty())
         {
             LOG.error("No IDAT chunks.");
             return false;
@@ -718,26 +746,6 @@ final class PNGConverter
         return v / 100000f;
     }
 
-    // Chunk Type definitions. The bytes in the comments are the bytes in the spec.
-    private static final int CHUNK_IHDR = 0x49484452; // IHDR: 73 72 68 82
-    private static final int CHUNK_IDAT = 0x49444154; // IDAT: 73 68 65 84
-    private static final int CHUNK_PLTE = 0x504C5445; // PLTE: 80 76 84 69
-    private static final int CHUNK_IEND = 0x49454E44; // IEND: 73 69 78 68
-    private static final int CHUNK_TRNS = 0x74524E53; // tRNS: 116 82 78 83
-    private static final int CHUNK_CHRM = 0x6348524D; // cHRM: 99 72 82 77
-    private static final int CHUNK_GAMA = 0x67414D41; // gAMA: 103 65 77 65
-    private static final int CHUNK_ICCP = 0x69434350; // iCCP: 105 67 67 80
-    private static final int CHUNK_SBIT = 0x73424954; // sBIT: 115 66 73 84
-    private static final int CHUNK_SRGB = 0x73524742; // sRGB: 115 82 71 66
-    private static final int CHUNK_TEXT = 0x74455874; // tEXt: 116 69 88 116
-    private static final int CHUNK_ZTXT = 0x7A545874; // zTXt: 122 84 88 116
-    private static final int CHUNK_ITXT = 0x69545874; // iTXt: 105 84 88 116
-    private static final int CHUNK_KBKG = 0x6B424B47; // kBKG: 107 66 75 71
-    private static final int CHUNK_HIST = 0x68495354; // hIST: 104 73 83 84
-    private static final int CHUNK_PHYS = 0x70485973; // pHYs: 112 72 89 115
-    private static final int CHUNK_SPLT = 0x73504C54; // sPLT: 115 80 76 84
-    private static final int CHUNK_TIME = 0x74494D45; // tIME: 116 73 77 69
-
     /**
      * Parse the PNG structure into the PNGConverterState. If we can't handle
      * something, this method will return null.
@@ -876,14 +884,6 @@ final class PNGConverter
     // https://www.w3.org/TR/2003/REC-PNG-20031110/#D-CRCAppendix
     // for details
 
-    /* Table of CRCs of all 8-bit messages. */
-    private static final int[] CRC_TABLE = new int[256];
-
-    static
-    {
-        makeCrcTable();
-    }
-
     /* Make the table for a fast CRC. */
     private static void makeCrcTable()
     {