You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/11/27 13:37:29 UTC

(commons-imaging) 01/11: Make org.apache.commons.imaging.formats.pcx.PcxWriter.encoding final

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git

commit 86513042a07ce0581985f7bd8ac01193b78560dd
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 27 08:11:57 2023 -0500

    Make org.apache.commons.imaging.formats.pcx.PcxWriter.encoding final
---
 .../java/org/apache/commons/imaging/formats/pcx/PcxWriter.java   | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
index fbe2ee25..5243ca67 100644
--- a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
+++ b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
@@ -27,7 +27,7 @@ import org.apache.commons.imaging.palette.PaletteFactory;
 import org.apache.commons.imaging.palette.SimplePalette;
 
 final class PcxWriter {
-    private int encoding;
+    private final int encoding;
     private int bitDepthWanted = -1;
     private int planesWanted = -1;
     private PixelDensity pixelDensity;
@@ -39,11 +39,8 @@ final class PcxWriter {
         if (params == null) {
             params = new PcxImagingParameters();
         }
-        encoding = PcxImageParser.PcxHeader.ENCODING_RLE;
-        final int compression = params.getCompression();
-        if (compression == PcxConstants.PCX_COMPRESSION_UNCOMPRESSED) {
-            encoding = PcxImageParser.PcxHeader.ENCODING_UNCOMPRESSED;
-        }
+        encoding = params.getCompression() == PcxConstants.PCX_COMPRESSION_UNCOMPRESSED ? PcxImageParser.PcxHeader.ENCODING_UNCOMPRESSED
+                : PcxImageParser.PcxHeader.ENCODING_RLE;
         if (encoding == PcxImageParser.PcxHeader.ENCODING_UNCOMPRESSED) {
             rleWriter = new RleWriter(false);
         } else {