incubator-sanselan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmc...@apache.org
Subject svn commit: r682118 - in /incubator/sanselan/trunk: RELEASE_NOTES src/main/java/org/apache/sanselan/common/ZLibInflater.java src/test/java/org/apache/sanselan/roundtrip/RoundtripTest.java
Date Sun, 03 Aug 2008 09:20:49 GMT
Author: cmchen
Date: Sun Aug  3 02:20:48 2008
New Revision: 682118

URL: http://svn.apache.org/viewvc?rev=682118&view=rev
Log:
* Replaced dependency on java.util.zip.DeflaterOutputStream, which is only available in Java
1.6.

Modified:
    incubator/sanselan/trunk/RELEASE_NOTES
    incubator/sanselan/trunk/src/main/java/org/apache/sanselan/common/ZLibInflater.java
    incubator/sanselan/trunk/src/test/java/org/apache/sanselan/roundtrip/RoundtripTest.java

Modified: incubator/sanselan/trunk/RELEASE_NOTES
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/RELEASE_NOTES?rev=682118&r1=682117&r2=682118&view=diff
==============================================================================
--- incubator/sanselan/trunk/RELEASE_NOTES (original)
+++ incubator/sanselan/trunk/RELEASE_NOTES Sun Aug  3 02:20:48 2008
@@ -15,7 +15,8 @@
 Release 0.95
 ------------
 
- * Added a wide-reaching unit test around reading and writing images.
+ * Replaced dependency on java.util.zip.DeflaterOutputStream, which is only available in
Java 1.6.
+ * Added a unit test around reading and writing images in every format.
  * We now sort some (but not all) GIF color tables.
  * Applied the BMP "buffer flushing" bug to the PBM reading and writing code.
  * Fixed a regression around flushing the bit buffer when writing BMPs with very small palettes.

Modified: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/common/ZLibInflater.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/common/ZLibInflater.java?rev=682118&r1=682117&r2=682118&view=diff
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/common/ZLibInflater.java (original)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/common/ZLibInflater.java Sun
Aug  3 02:20:48 2008
@@ -17,12 +17,11 @@
 package org.apache.sanselan.common;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.util.zip.DeflaterInputStream;
+import java.util.zip.DeflaterOutputStream;
 import java.util.zip.InflaterInputStream;
 
-import org.apache.sanselan.ImageReadException;
-
 public class ZLibInflater extends BinaryFileFunctions
 {
 	public final byte[] inflate(byte bytes[]) throws IOException
@@ -35,9 +34,11 @@
 
 	public final byte[] deflate(byte bytes[]) throws IOException
 	{
-		ByteArrayInputStream in = new ByteArrayInputStream(bytes);
-		DeflaterInputStream zIn = new DeflaterInputStream(in);
-		return getStreamBytes(zIn);
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+		DeflaterOutputStream dos = new DeflaterOutputStream(baos);
+		dos.write(bytes);
+		dos.flush();
+		return baos.toByteArray();
 	}
 
 }

Modified: incubator/sanselan/trunk/src/test/java/org/apache/sanselan/roundtrip/RoundtripTest.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/test/java/org/apache/sanselan/roundtrip/RoundtripTest.java?rev=682118&r1=682117&r2=682118&view=diff
==============================================================================
--- incubator/sanselan/trunk/src/test/java/org/apache/sanselan/roundtrip/RoundtripTest.java
(original)
+++ incubator/sanselan/trunk/src/test/java/org/apache/sanselan/roundtrip/RoundtripTest.java
Sun Aug  3 02:20:48 2008
@@ -272,75 +272,75 @@
 		}
 	}
 
-	 public void testBitmapRoundtrip() throws IOException, ImageReadException,
-	 ImageWriteException
-	 {
-	 BufferedImage testImages[] = { //
-	
-	 createArgbBitmapImage(1, 1), // minimal
-	 createArgbBitmapImage(2, 2), //
-	 createArgbBitmapImage(10, 10), // larger than 8
-	 createArgbBitmapImage(300, 300), // larger than 256
-	
-	 createBitmapBitmapImage(1, 1), // minimal
-	 createBitmapBitmapImage(2, 2), //
-	 createBitmapBitmapImage(10, 10), // larger than 8
-	 createBitmapBitmapImage(300, 300), // larger than 256
-	 };
-	
-	 for (int j = 0; j < testImages.length; j++)
-	 {
-	 BufferedImage testImage = testImages[j];
-	
-	 for (int i = 0; i < FORMAT_INFOS.length; i++)
-	 {
-	 FormatInfo formatInfo = FORMAT_INFOS[i];
-	 if ((!formatInfo.canRead) || (!formatInfo.canWrite))
-	 continue;
-	
-	 Debug.debug("bitmap test: " + formatInfo.format.name);
-	
-	 testRoundtrip(formatInfo, testImage, "bitmap", true);
-	 }
-	 }
-	 }
-
-	 public void testGrayscaleRoundtrip() throws IOException,
-	 ImageReadException, ImageWriteException
-	 {
-	 BufferedImage testImages[] = { //
-	
-	 createArgbBitmapImage(1, 1), // minimal
-	 createArgbGrayscaleImage(2, 2), //
-	 createArgbGrayscaleImage(10, 10), // larger than 8
-	 createArgbGrayscaleImage(300, 300), // larger than 256
-	
-	 createGrayscaleGrayscaleImage(1, 1), // minimal
-	 createGrayscaleGrayscaleImage(2, 2), //
-	 createGrayscaleGrayscaleImage(10, 10), // larger than 8
-	 createGrayscaleGrayscaleImage(300, 300), // larger than 256
-	 };
-	
-	 for (int j = 0; j < testImages.length; j++)
-	 {
-	 BufferedImage testImage = testImages[j];
-	
-	 for (int i = 0; i < FORMAT_INFOS.length; i++)
-	 {
-	 FormatInfo formatInfo = FORMAT_INFOS[i];
-	 if ((!formatInfo.canRead) || (!formatInfo.canWrite))
-	 continue;
-	
-	 Debug.debug("grayscale test: " + formatInfo.format.name);
-	
-	 boolean imageExact = true;
-	 if (formatInfo.colorSupport == COLOR_BITMAP)
-	 imageExact = false;
-	
-	 testRoundtrip(formatInfo, testImage, "gray", imageExact);
-	 }
-	 }
-	 }
+	public void testBitmapRoundtrip() throws IOException, ImageReadException,
+			ImageWriteException
+	{
+		BufferedImage testImages[] = { //
+
+		createArgbBitmapImage(1, 1), // minimal
+				createArgbBitmapImage(2, 2), //
+				createArgbBitmapImage(10, 10), // larger than 8
+				createArgbBitmapImage(300, 300), // larger than 256
+
+				createBitmapBitmapImage(1, 1), // minimal
+				createBitmapBitmapImage(2, 2), //
+				createBitmapBitmapImage(10, 10), // larger than 8
+				createBitmapBitmapImage(300, 300), // larger than 256
+		};
+
+		for (int j = 0; j < testImages.length; j++)
+		{
+			BufferedImage testImage = testImages[j];
+
+			for (int i = 0; i < FORMAT_INFOS.length; i++)
+			{
+				FormatInfo formatInfo = FORMAT_INFOS[i];
+				if ((!formatInfo.canRead) || (!formatInfo.canWrite))
+					continue;
+
+				Debug.debug("bitmap test: " + formatInfo.format.name);
+
+				roundtrip(formatInfo, testImage, "bitmap", true);
+			}
+		}
+	}
+
+	public void testGrayscaleRoundtrip() throws IOException,
+			ImageReadException, ImageWriteException
+	{
+		BufferedImage testImages[] = { //
+
+		createArgbBitmapImage(1, 1), // minimal
+				createArgbGrayscaleImage(2, 2), //
+				createArgbGrayscaleImage(10, 10), // larger than 8
+				createArgbGrayscaleImage(300, 300), // larger than 256
+
+				createGrayscaleGrayscaleImage(1, 1), // minimal
+				createGrayscaleGrayscaleImage(2, 2), //
+				createGrayscaleGrayscaleImage(10, 10), // larger than 8
+				createGrayscaleGrayscaleImage(300, 300), // larger than 256
+		};
+
+		for (int j = 0; j < testImages.length; j++)
+		{
+			BufferedImage testImage = testImages[j];
+
+			for (int i = 0; i < FORMAT_INFOS.length; i++)
+			{
+				FormatInfo formatInfo = FORMAT_INFOS[i];
+				if ((!formatInfo.canRead) || (!formatInfo.canWrite))
+					continue;
+
+				Debug.debug("grayscale test: " + formatInfo.format.name);
+
+				boolean imageExact = true;
+				if (formatInfo.colorSupport == COLOR_BITMAP)
+					imageExact = false;
+
+				roundtrip(formatInfo, testImage, "gray", imageExact);
+			}
+		}
+	}
 
 	public void testLimitedColorRoundtrip() throws IOException,
 			ImageReadException, ImageWriteException
@@ -371,12 +371,11 @@
 				if (formatInfo.colorSupport == COLOR_GRAYSCALE)
 					imageExact = false;
 
-				testRoundtrip(formatInfo, testImage, "indexable", imageExact);
+				roundtrip(formatInfo, testImage, "indexable", imageExact);
 			}
 		}
 	}
 
-
 	public void testFullColorRoundtrip() throws IOException,
 			ImageReadException, ImageWriteException
 	{
@@ -407,13 +406,13 @@
 					imageExact = false;
 				if (formatInfo.colorSupport == COLOR_LIMITED_INDEX)
 					imageExact = false;
-				
-				testRoundtrip(formatInfo, testImage, "fullColor", imageExact);
+
+				roundtrip(formatInfo, testImage, "fullColor", imageExact);
 			}
 		}
 	}
 
-	private void testRoundtrip(FormatInfo formatInfo, BufferedImage testImage,
+	private void roundtrip(FormatInfo formatInfo, BufferedImage testImage,
 			String tempPrefix, boolean imageExact) throws IOException,
 			ImageReadException, ImageWriteException
 	{



Mime
View raw message