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/13 19:10:24 UTC
(commons-imaging) 01/02: Sort members
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 14347e910f853dde31e7960e0abb941797300dec
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 13 14:09:42 2023 -0500
Sort members
---
.../imaging/formats/jpeg/decoder/JpegDecoder.java | 18 +++---
.../imaging/formats/png/PngWriteReadTest.java | 14 ++---
.../commons/imaging/formats/tiff/TiffJpegTest.java | 68 +++++++++++-----------
3 files changed, 50 insertions(+), 50 deletions(-)
diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
index f2b72eec..78553fb8 100644
--- a/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
+++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
@@ -348,6 +348,15 @@ public class JpegDecoder extends BinaryFileParser implements JpegUtils.Visitor {
}
}
+ /**
+ * Sets the decoder to treat incoming data as using the RGB color model.
+ * This extension to the JPEG specification is intended to support
+ * TIFF files that use JPEG compression.
+ */
+ public void setTiffRgb() {
+ useTiffRgb = true;
+ }
+
@Override
public boolean visitSegment(final int marker, final byte[] markerBytes,
final int segmentLength, final byte[] segmentLengthBytes, final byte[] segmentData)
@@ -616,13 +625,4 @@ public class JpegDecoder extends BinaryFileParser implements JpegUtils.Visitor {
imageReadException = new ImagingException("Error parsing JPEG", ex);
}
}
-
- /**
- * Sets the decoder to treat incoming data as using the RGB color model.
- * This extension to the JPEG specification is intended to support
- * TIFF files that use JPEG compression.
- */
- public void setTiffRgb() {
- useTiffRgb = true;
- }
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/png/PngWriteReadTest.java b/src/test/java/org/apache/commons/imaging/formats/png/PngWriteReadTest.java
index 6ae3eedd..e2ba962d 100644
--- a/src/test/java/org/apache/commons/imaging/formats/png/PngWriteReadTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/png/PngWriteReadTest.java
@@ -102,13 +102,6 @@ public class PngWriteReadTest extends AbstractImagingTest {
return result;
}
- @Test
- public void testMultipletEXt() throws Exception {
- final int[][] smallBlackPixels = getSimpleRawData(256, 256, 0);
-
- writeAndReadMultipleEXt(smallBlackPixels);
- }
-
@Test
public void test() throws Exception {
final int[][] smallBlackPixels = getSimpleRawData(256, 256, 0);
@@ -127,6 +120,13 @@ public class PngWriteReadTest extends AbstractImagingTest {
}
}
+ @Test
+ public void testMultipletEXt() throws Exception {
+ final int[][] smallBlackPixels = getSimpleRawData(256, 256, 0);
+
+ writeAndReadMultipleEXt(smallBlackPixels);
+ }
+
@Test
public void testPhysicalScaleMeters() throws Exception {
final PngImageParser pngImageParser = new PngImageParser();
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffJpegTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffJpegTest.java
index 237d454d..4458b733 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffJpegTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffJpegTest.java
@@ -63,6 +63,40 @@ public class TiffJpegTest extends TiffBaseTest {
return (int) (0.299 * r + 0.587 * g + 0.114 * b + 0.5);
}
+ void performSubImageTest(String name) throws IOException {
+ // get the full image to be used as a basis for comparison
+ File target = getTiffFile(name);
+ BufferedImage master = Imaging.getBufferedImage(target);
+ int w = master.getWidth();
+ int h = master.getHeight();
+ int[] masterArgb = new int[w * h];
+ master.getRGB(0, 0, w, h, masterArgb, 0, w);
+
+ // Get a subimage
+ TiffImageParser tiffImageParser = new TiffImageParser();
+ TiffImagingParameters params = new TiffImagingParameters();
+ int testX0 = 11;
+ int testY0 = 11;
+ int testW = w - testX0 - 1;
+ int testH = h - testY0 - 1;
+ params.setSubImage(testX0, testY0, testW, testH);
+
+ BufferedImage test = tiffImageParser.getBufferedImage(target, params);
+ int[] testArgb = new int[testW * testH];
+ test.getRGB(0, 0, testW, testH, testArgb, 0, testW);
+ String label = "Pixel mismatch for " + name;
+ for (int i = 0; i < testH; i++) {
+ for (int j = 0; j < testH; j++) {
+ int masterIndex = (i + testY0) * w + (j + testX0);
+ int testIndex = i * testW + j;
+ int masterPixel = masterArgb[masterIndex];
+ int testPixel = testArgb[testIndex];
+ assertEquals(masterPixel, testPixel, label);
+ }
+ }
+
+ }
+
/**
* Process a set of files using the first name in the array as
* the master image and comparing all subsequent files against its
@@ -111,40 +145,6 @@ public class TiffJpegTest extends TiffBaseTest {
}
}
- void performSubImageTest(String name) throws IOException {
- // get the full image to be used as a basis for comparison
- File target = getTiffFile(name);
- BufferedImage master = Imaging.getBufferedImage(target);
- int w = master.getWidth();
- int h = master.getHeight();
- int[] masterArgb = new int[w * h];
- master.getRGB(0, 0, w, h, masterArgb, 0, w);
-
- // Get a subimage
- TiffImageParser tiffImageParser = new TiffImageParser();
- TiffImagingParameters params = new TiffImagingParameters();
- int testX0 = 11;
- int testY0 = 11;
- int testW = w - testX0 - 1;
- int testH = h - testY0 - 1;
- params.setSubImage(testX0, testY0, testW, testH);
-
- BufferedImage test = tiffImageParser.getBufferedImage(target, params);
- int[] testArgb = new int[testW * testH];
- test.getRGB(0, 0, testW, testH, testArgb, 0, testW);
- String label = "Pixel mismatch for " + name;
- for (int i = 0; i < testH; i++) {
- for (int j = 0; j < testH; j++) {
- int masterIndex = (i + testY0) * w + (j + testX0);
- int testIndex = i * testW + j;
- int masterPixel = masterArgb[masterIndex];
- int testPixel = testArgb[testIndex];
- assertEquals(masterPixel, testPixel, label);
- }
- }
-
- }
-
/**
* Verify that TIFF files using JPEG compression provide a pixel-by-pixel
* match with source files that use a lossless compression.