Author: damjan
Date: Wed Oct 3 19:35:48 2012
New Revision: 1393718
URL: http://svn.apache.org/viewvc?rev=1393718&view=rev
Log:
Add support for the PAM file format, and some tests for it.
Added:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java
(with props)
commons/proper/imaging/trunk/src/test/data/images/pbm/2/
commons/proper/imaging/trunk/src/test/data/images/pbm/2/5x5.pam (with
props)
commons/proper/imaging/trunk/src/test/data/images/pbm/2/info.txt (with
props)
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/pam/
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/pam/PamBaseTest.java
(with props)
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/pam/PamReadTest.java
(with props)
Modified:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmConstants.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReader.java
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java
Modified:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java?rev=1393718&r1=1393717&r2=1393718&view=diff
==============================================================================
---
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java
(original)
+++
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/Imaging.java
Wed Oct 3 19:35:48 2012
@@ -180,6 +180,7 @@ public abstract class Imaging implements
private static final int[] MAGIC_NUMBERS_BMP = { 0x42, 0x4d, };
private static final int[] MAGIC_NUMBERS_TIFF_MOTOROLA = { 0x4D, 0x4D, };
private static final int[] MAGIC_NUMBERS_TIFF_INTEL = { 0x49, 0x49, };
+ private static final int[] MAGIC_NUMBERS_PAM = { 0x50, 0x37, };
private static final int[] MAGIC_NUMBERS_PSD = { 0x38, 0x42, };
private static final int[] MAGIC_NUMBERS_PBM_A = { 0x50, 0x31, };
private static final int[] MAGIC_NUMBERS_PBM_B = { 0x50, 0x34, };
@@ -262,6 +263,8 @@ public abstract class Imaging implements
return ImageFormat.IMAGE_FORMAT_TIFF;
} else if (compareBytePair(MAGIC_NUMBERS_PSD, bytePair)) {
return ImageFormat.IMAGE_FORMAT_PSD;
+ } else if (compareBytePair(MAGIC_NUMBERS_PAM, bytePair)) {
+ return ImageFormat.IMAGE_FORMAT_PAM;
} else if (compareBytePair(MAGIC_NUMBERS_PBM_A, bytePair)) {
return ImageFormat.IMAGE_FORMAT_PBM;
} else if (compareBytePair(MAGIC_NUMBERS_PBM_B, bytePair)) {
Added:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java?rev=1393718&view=auto
==============================================================================
---
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java
(added)
+++
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java
Wed Oct 3 19:35:48 2012
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.imaging.formats.pnm;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.commons.imaging.ImageFormat;
+import org.apache.commons.imaging.ImageInfo;
+import org.apache.commons.imaging.ImageReadException;
+
+public class PamFileInfo extends FileInfo {
+ private int depth;
+ private int maxval;
+ private final float scale;
+ private final int bytesPerSample;
+ private boolean hasAlpha;
+ private final TupleReader tupleReader;
+
+ PamFileInfo(int width, int height, int depth, int maxval, String
tupleType) throws ImageReadException {
+ super(width, height, true);
+ this.depth = depth;
+ this.maxval = maxval;
+ if (maxval <= 0) {
+ throw new ImageReadException("PAM maxVal " + maxval
+ + " is out of range [1;65535]");
+ } else if (maxval <= 255) {
+ scale = 255f;
+ bytesPerSample = 1;
+ } else if (maxval <= 65535) {
+ scale = 65535f;
+ bytesPerSample = 2;
+ } else {
+ throw new ImageReadException("PAM maxVal " + maxval
+ + " is out of range [1;65535]");
+ }
+
+ hasAlpha = tupleType.endsWith("_ALPHA");
+ if (tupleType.equals("BLACKANDWHITE") ||
tupleType.equals("BLACKANDWHITE_ALPHA")) {
+ tupleReader = new BlackAndWhiteTupleReader();
+ } else if (tupleType.equals("GRAYSCALE") ||
tupleType.equals("GRAYSCALE_ALPHA")) {
+ tupleReader = new GrayscaleTupleReader();
+ } else if (tupleType.equals("RGB") || tupleType.equals("RGB_ALPHA")) {
+ tupleReader = new ColorTupleReader();
+ } else {
+ throw new ImageReadException("Unknown PAM tupletype '" + tupleType
+ "'");
+ }
+ }
+
+ @Override
+ public int getNumComponents() {
+ return depth;
+ }
+
+ @Override
+ public int getBitDepth() {
+ return maxval;
+ }
+
+ @Override
+ public ImageFormat getImageType() {
+ return ImageFormat.IMAGE_FORMAT_PAM;
+ }
+
+ @Override
+ public String getImageTypeDescription() {
+ return "PAM: portable arbitrary map file format";
+ }
+
+ @Override
+ public String getMIMEType() {
+ return "image/x-portable-arbitrary-map";
+ }
+
+ @Override
+ public int getColorType() {
+ return tupleReader.getColorType();
+ }
+
+ @Override
+ protected void newline() {
+ tupleReader.newline();
+ }
+
+ @Override
+ public int getRGB(WhiteSpaceReader wsr) throws IOException {
+ throw new UnsupportedOperationException("PAM files are only ever
binary");
+ }
+
+ @Override
+ public int getRGB(InputStream is) throws IOException {
+ return tupleReader.getRGB(is);
+ }
+
+ private abstract class TupleReader {
+ public abstract int getColorType();
+ public abstract int getRGB(InputStream is) throws IOException;
+ public void newline() {
+ }
+ }
+
+ private class BlackAndWhiteTupleReader extends TupleReader {
+ private int bitcache = 0;
+ private int bits_in_cache = 0;
+
+ @Override
+ public int getColorType() {
+ return ImageInfo.COLOR_TYPE_BW;
+ }
+
+ @Override
+ public int getRGB(InputStream is) throws IOException {
+ if (bits_in_cache < 1) {
+ int bits = is.read();
+ if (bits < 0) {
+ throw new IOException("PAM: Unexpected EOF");
+ }
+ bitcache = 0xff & bits;
+ bits_in_cache += 8;
+ }
+
+ int alpha = 0xff000000;
+ if (hasAlpha) {
+ int alphaBit = 0x1 & (bitcache >> 7);
+ bitcache <<= 1;
+ bits_in_cache--;
+ alpha = alphaBit * 0xff000000;
+ }
+
+ int bit = 0x1 & (bitcache >> 7);
+ bitcache <<= 1;
+ bits_in_cache--;
+
+ if (bit == 0) {
+ return alpha | 0x000000;
+ }
+ if (bit == 1) {
+ return alpha | 0xffffff;
+ }
+ throw new IOException("PAM: bad bit: " + bit);
+ }
+
+ @Override
+ public void newline() {
+ bitcache = 0;
+ bits_in_cache = 0;
+ }
+ }
+
+ private class GrayscaleTupleReader extends TupleReader {
+ @Override
+ public int getColorType() {
+ return ImageInfo.COLOR_TYPE_GRAYSCALE;
+ }
+
+ @Override
+ public int getRGB(InputStream is) throws IOException {
+ int alpha = 0xff;
+ if (hasAlpha) {
+ alpha = readSample(is, bytesPerSample);
+ alpha = scaleSample(alpha, scale, maxval);
+ }
+
+ int sample = readSample(is, bytesPerSample);
+ sample = scaleSample(sample, scale, maxval);
+
+ int rgb = ((0xff & alpha) << 24) | ((0xff & sample) << 16)
+ | ((0xff & sample) << 8) | ((0xff & sample) << 0);
+
+ return rgb;
+ }
+ }
+
+ private class ColorTupleReader extends TupleReader {
+ @Override
+ public int getColorType() {
+ return ImageInfo.COLOR_TYPE_RGB;
+ }
+
+ @Override
+ public int getRGB(InputStream is) throws IOException {
+ int alpha = 0xff;
+ if (hasAlpha) {
+ alpha = readSample(is, bytesPerSample);
+ alpha = scaleSample(alpha, scale, maxval);
+ }
+ int red = readSample(is, bytesPerSample);
+ int green = readSample(is, bytesPerSample);
+ int blue = readSample(is, bytesPerSample);
+
+ red = scaleSample(red, scale, maxval);
+ green = scaleSample(green, scale, maxval);
+ blue = scaleSample(blue, scale, maxval);
+
+ int rgb = ((0xff & alpha) << 24) | ((0xff & red) << 16)
+ | ((0xff & green) << 8) | ((0xff & blue) << 0);
+
+ return rgb;
+ }
+ }
+}
Propchange:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PamFileInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmConstants.java
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmConstants.java?rev=1393718&r1=1393717&r2=1393718&view=diff
==============================================================================
---
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmConstants.java
(original)
+++
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmConstants.java
Wed Oct 3 19:35:48 2012
@@ -25,6 +25,7 @@ public interface PnmConstants {
public static final byte PGM_RAW_CODE = 0x35; // RAW GrayMap
public static final byte PBM_RAW_CODE = 0x34; // RAW Bitmap
public static final byte PPM_RAW_CODE = 0x36; // RAW Pixmap
+ public static final byte PAM_TEXT_CODE = 0x37; // PAM Pixmap
public static final byte PNM_SEPARATOR = 0x20; // Space
public static final byte PNM_NEWLINE = 0x0A; // "usually a newline"
Modified:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java?rev=1393718&r1=1393717&r2=1393718&view=diff
==============================================================================
---
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java
(original)
+++
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java
Wed Oct 3 19:35:48 2012
@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.StringTokenizer;
import org.apache.commons.imaging.ImageFormat;
import org.apache.commons.imaging.ImageInfo;
@@ -59,7 +60,7 @@ public class PnmImageParser extends Imag
private static final String DEFAULT_EXTENSION = ".pnm";
private static final String ACCEPTED_EXTENSIONS[] = { ".pbm", ".pgm",
- ".ppm", ".pnm", };
+ ".ppm", ".pnm", ".pam" };
@Override
protected String[] getAcceptedExtensions() {
@@ -68,10 +69,13 @@ public class PnmImageParser extends Imag
@Override
protected ImageFormat[] getAcceptedTypes() {
- return new ImageFormat[] { ImageFormat.IMAGE_FORMAT_PBM, //
+ return new ImageFormat[] {
+ ImageFormat.IMAGE_FORMAT_PBM, //
ImageFormat.IMAGE_FORMAT_PGM, //
ImageFormat.IMAGE_FORMAT_PPM, //
- ImageFormat.IMAGE_FORMAT_PNM, };
+ ImageFormat.IMAGE_FORMAT_PNM,
+ ImageFormat.IMAGE_FORMAT_PAM
+ };
}
private FileInfo readHeader(InputStream is) throws ImageReadException,
@@ -79,41 +83,100 @@ public class PnmImageParser extends Imag
byte identifier1 = readByte("Identifier1", is, "Not a Valid PNM File");
byte identifier2 = readByte("Identifier2", is, "Not a Valid PNM File");
- WhiteSpaceReader wsr = new WhiteSpaceReader(is);
-
- int width = Integer.parseInt(wsr.readtoWhiteSpace());
- int height = Integer.parseInt(wsr.readtoWhiteSpace());
-
- // System.out.println("width: " + width);
- // System.out.println("height: " + height);
- // System.out.println("width*height: " + width * height);
- // System.out.println("3*width*height: " + 3 * width * height);
- // System.out.println("((width*height+7)/8): "
- // + ((width * height + 7) / 8));
-
if (identifier1 != PNM_PREFIX_BYTE) {
- throw new ImageReadException("PNM file has invalid header.");
+ throw new ImageReadException("PNM file has invalid prefix byte 1");
}
-
- if (identifier2 == PBM_TEXT_CODE) {
- return new PbmFileInfo(width, height, false);
- } else if (identifier2 == PBM_RAW_CODE) {
- return new PbmFileInfo(width, height, true);
- } else if (identifier2 == PGM_TEXT_CODE) {
- int maxgray = Integer.parseInt(wsr.readtoWhiteSpace());
- return new PgmFileInfo(width, height, false, maxgray);
- } else if (identifier2 == PGM_RAW_CODE) {
- int maxgray = Integer.parseInt(wsr.readtoWhiteSpace());
- return new PgmFileInfo(width, height, true, maxgray);
- } else if (identifier2 == PPM_TEXT_CODE) {
- int max = Integer.parseInt(wsr.readtoWhiteSpace());
- return new PpmFileInfo(width, height, false, max);
- } else if (identifier2 == PPM_RAW_CODE) {
- int max = Integer.parseInt(wsr.readtoWhiteSpace());
- // System.out.println("max: " + max);
- return new PpmFileInfo(width, height, true, max);
+
+ WhiteSpaceReader wsr = new WhiteSpaceReader(is);
+
+ if (identifier2 == PBM_TEXT_CODE ||
+ identifier2 == PBM_RAW_CODE ||
+ identifier2 == PGM_TEXT_CODE ||
+ identifier2 == PGM_RAW_CODE ||
+ identifier2 == PPM_TEXT_CODE ||
+ identifier2 == PPM_RAW_CODE) {
+
+ int width = Integer.parseInt(wsr.readtoWhiteSpace());
+ int height = Integer.parseInt(wsr.readtoWhiteSpace());
+
+ if (identifier2 == PBM_TEXT_CODE) {
+ return new PbmFileInfo(width, height, false);
+ } else if (identifier2 == PBM_RAW_CODE) {
+ return new PbmFileInfo(width, height, true);
+ } else if (identifier2 == PGM_TEXT_CODE) {
+ int maxgray = Integer.parseInt(wsr.readtoWhiteSpace());
+ return new PgmFileInfo(width, height, false, maxgray);
+ } else if (identifier2 == PGM_RAW_CODE) {
+ int maxgray = Integer.parseInt(wsr.readtoWhiteSpace());
+ return new PgmFileInfo(width, height, true, maxgray);
+ } else if (identifier2 == PPM_TEXT_CODE) {
+ int max = Integer.parseInt(wsr.readtoWhiteSpace());
+ return new PpmFileInfo(width, height, false, max);
+ } else if (identifier2 == PPM_RAW_CODE) {
+ int max = Integer.parseInt(wsr.readtoWhiteSpace());
+ return new PpmFileInfo(width, height, true, max);
+ } else {
+ throw new ImageReadException("PNM file has invalid header.");
+ }
+ } else if (identifier2 == PAM_TEXT_CODE) {
+ int width = -1;
+ boolean seenWidth = false;
+ int height = -1;
+ boolean seenHeight = false;
+ int depth = -1;
+ boolean seenDepth = false;
+ int maxVal = -1;
+ boolean seenMaxVal = false;
+ String tupleType = "";
+ boolean seenTupleType = false;
+
+ // Advance to next line
+ wsr.readLine();
+ String line;
+ while ((line = wsr.readLine()) != null) {
+ line = line.trim();
+ if (line.startsWith("#")) {
+ continue;
+ }
+ StringTokenizer tokenizer = new StringTokenizer(line, " ",
false);
+ String type = tokenizer.nextToken();
+ if (type.equals("WIDTH")) {
+ seenWidth = true;
+ width = Integer.parseInt(tokenizer.nextToken());
+ } else if (type.equals("HEIGHT")) {
+ seenHeight = true;
+ height = Integer.parseInt(tokenizer.nextToken());
+ } else if (type.equals("DEPTH")) {
+ seenDepth = true;
+ depth = Integer.parseInt(tokenizer.nextToken());
+ } else if (type.equals("MAXVAL")) {
+ seenMaxVal = true;
+ maxVal = Integer.parseInt(tokenizer.nextToken());
+ } else if (type.equals("TUPLTYPE")) {
+ seenTupleType = true;
+ tupleType += tokenizer.nextToken();
+ } else if (type.equals("ENDHDR")) {
+ break;
+ } else {
+ throw new ImageReadException("Invalid PAM file header type
" + type);
+ }
+ }
+
+ if (!seenWidth) {
+ throw new ImageReadException("PAM header has no WIDTH");
+ } else if (!seenHeight) {
+ throw new ImageReadException("PAM header has no HEIGHT");
+ } else if (!seenDepth) {
+ throw new ImageReadException("PAM header has no DEPTH");
+ } else if (!seenMaxVal) {
+ throw new ImageReadException("PAM header has no MAXVAL");
+ } else if (!seenTupleType) {
+ throw new ImageReadException("PAM header has no TUPLTYPE");
+ }
+
+ return new PamFileInfo(width, height, depth, maxVal, tupleType);
} else {
- throw new ImageReadException("PNM file has invalid header.");
+ throw new ImageReadException("PNM file has invalid prefix byte 2");
}
}
Modified:
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReader.java
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReader.java?rev=1393718&r1=1393717&r2=1393718&view=diff
==============================================================================
---
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReader.java
(original)
+++
commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReader.java
Wed Oct 3 19:35:48 2012
@@ -61,4 +61,12 @@ class WhiteSpaceReader {
return buffer.toString();
}
+
+ public String readLine() throws IOException {
+ StringBuilder buffer = new StringBuilder();
+ for (char c = read(); (c != '\n') && (c != '\r'); c = read()) {
+ buffer.append(c);
+ }
+ return buffer.length() > 0 ? buffer.toString() : null;
+ }
}
Added: commons/proper/imaging/trunk/src/test/data/images/pbm/2/5x5.pam
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/data/images/pbm/2/5x5.pam?rev=1393718&view=auto
==============================================================================
Binary file - no diff available.
Propchange: commons/proper/imaging/trunk/src/test/data/images/pbm/2/5x5.pam
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: commons/proper/imaging/trunk/src/test/data/images/pbm/2/info.txt
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/data/images/pbm/2/info.txt?rev=1393718&view=auto
==============================================================================
--- commons/proper/imaging/trunk/src/test/data/images/pbm/2/info.txt (added)
+++ commons/proper/imaging/trunk/src/test/data/images/pbm/2/info.txt Wed Oct 3
19:35:48 2012
@@ -0,0 +1 @@
+Contributed to the project by Damjan Jovanovic
Propchange: commons/proper/imaging/trunk/src/test/data/images/pbm/2/info.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added:
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/pam/PamBaseTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/pam/PamBaseTest.java?rev=1393718&view=auto
==============================================================================
---
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/pam/PamBaseTest.java
(added)
+++
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/pam/PamBaseTest.java
Wed Oct 3 19:35:48 2012
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.imaging.formats.pam;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.commons.imaging.ImageFormat;
+import org.apache.commons.imaging.ImageReadException;
+import org.apache.commons.imaging.Imaging;
+import org.apache.commons.imaging.ImagingTest;
+
+public abstract class PamBaseTest extends ImagingTest {
+
+ private static boolean isPam(File file) throws IOException,
+ ImageReadException {
+ ImageFormat format = Imaging.guessFormat(file);
+ return format == ImageFormat.IMAGE_FORMAT_PAM;
+ }
+
+ private static final ImageFilter IMAGE_FILTER = new ImageFilter() {
+ public boolean accept(File file) throws IOException,
ImageReadException {
+ return isPam(file);
+ }
+ };
+
+ protected List<File> getPamImages() throws IOException, ImageReadException
{
+ return getTestImages(IMAGE_FILTER);
+ }
+}
Propchange:
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/pam/PamBaseTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/pam/PamReadTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/pam/PamReadTest.java?rev=1393718&view=auto
==============================================================================
---
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/pam/PamReadTest.java
(added)
+++
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/pam/PamReadTest.java
Wed Oct 3 19:35:48 2012
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.imaging.formats.pam;
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.imaging.ImageInfo;
+import org.apache.commons.imaging.Imaging;
+import org.apache.commons.imaging.common.IImageMetadata;
+import org.apache.commons.imaging.util.Debug;
+
+public class PamReadTest extends PamBaseTest {
+
+ public void test() throws Exception {
+ Debug.debug("start");
+
+ List<File> images = getPamImages();
+ for (int i = 0; i < images.size(); i++) {
+ if (i % 10 == 0)
+ Debug.purgeMemory();
+
+ File imageFile = images.get(i);
+ Debug.debug("imageFile", imageFile);
+
+ IImageMetadata metadata = Imaging.getMetadata(imageFile);
+ // assertNotNull(metadata);
+
+ Map<String,Object> params = new HashMap<String,Object>();
+ ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
+ assertNotNull(imageInfo);
+
+ BufferedImage image = Imaging.getBufferedImage(imageFile);
+ assertNotNull(image);
+ }
+ }
+
+}
Propchange:
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/pam/PamReadTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java?rev=1393718&r1=1393717&r2=1393718&view=diff
==============================================================================
---
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java
(original)
+++
commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java
Wed Oct 3 19:35:48 2012
@@ -84,6 +84,8 @@ public class RoundtripTest extends Imagi
COLOR_GRAYSCALE, true, false), //
new FormatInfo(ImageFormat.IMAGE_FORMAT_PPM, true, true,
COLOR_FULL_RGB, true, false), //
+ new FormatInfo(ImageFormat.IMAGE_FORMAT_PAM, true, false,
+ COLOR_FULL_RGB, true, true),//
// new FormatInfo(ImageFormat.IMAGE_FORMAT_PNM, true, true,
// COLOR_FULL_RGB, true), //
new FormatInfo(ImageFormat.IMAGE_FORMAT_TGA, false, false,