commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1085891 - in /commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm: PBMWriter.java PGMWriter.java PNMConstants.java PPMWriter.java
Date Sun, 27 Mar 2011 08:46:32 GMT
Author: damjan
Date: Sun Mar 27 08:46:32 2011
New Revision: 1085891

URL: http://svn.apache.org/viewvc?rev=1085891&view=rev
Log:
Use '\n' instead of ' ' to separate the PNM header from the image data.
ppm2tiff needs this to read PNM files written by Sanselan.
Also make the use of separator constants more consistent.

Modified:
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMWriter.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMWriter.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMConstants.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMWriter.java

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMWriter.java?rev=1085891&r1=1085890&r2=1085891&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMWriter.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMWriter.java
Sun Mar 27 08:46:32 2011
@@ -44,7 +44,7 @@ public class PBMWriter extends PNMWriter
         os.write(PNM_SEPARATOR);
 
         os.write(("" + height).getBytes());
-        os.write(PNM_SEPARATOR);
+        os.write(PNM_NEWLINE);
 
         int bitcache = 0;
         int bits_in_cache = 0;
@@ -90,4 +90,4 @@ public class PBMWriter extends PNMWriter
             }
         }
     }
-}
\ No newline at end of file
+}

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMWriter.java?rev=1085891&r1=1085890&r2=1085891&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMWriter.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMWriter.java
Sun Mar 27 08:46:32 2011
@@ -23,7 +23,7 @@ import java.util.Map;
 
 import org.apache.sanselan.ImageWriteException;
 
-public class PGMWriter extends PNMWriter
+public class PGMWriter extends PNMWriter implements PNMConstants
 {
     public PGMWriter(boolean RAWBITS)
     {
@@ -37,19 +37,19 @@ public class PGMWriter extends PNMWriter
         // (b1 == 0x50 && b2 == 0x36)
         os.write(0x50);
         os.write(RAWBITS ? 0x35 : 0x32);
-        os.write(' ');
+        os.write(PNM_SEPARATOR);
 
         int width = src.getWidth();
         int height = src.getHeight();
 
         os.write(("" + width).getBytes());
-        os.write(' ');
+        os.write(PNM_SEPARATOR);
 
         os.write(("" + height).getBytes());
-        os.write(' ');
+        os.write(PNM_SEPARATOR);
 
         os.write(("" + 255).getBytes()); // max component value
-        os.write('\n');
+        os.write(PNM_NEWLINE);
 
         for (int y = 0; y < height; y++)
             for (int x = 0; x < width; x++)
@@ -67,9 +67,9 @@ public class PGMWriter extends PNMWriter
                 else
                 {
                     os.write(("" + sample).getBytes()); // max component value
-                    os.write(' ');
+                    os.write(PNM_SEPARATOR);
                 }
             }
     }
 
-}
\ No newline at end of file
+}

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMConstants.java?rev=1085891&r1=1085890&r2=1085891&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMConstants.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMConstants.java
Sun Mar 27 08:46:32 2011
@@ -28,5 +28,5 @@ public interface PNMConstants
     public static final byte PPM_RAW_CODE = 0x36; // RAW Pixmap
 
     public static final byte PNM_SEPARATOR = 0x20; // Space
-
-}
\ No newline at end of file
+    public static final byte PNM_NEWLINE = 0x0A; // "usually a newline" (http://netpbm.sourceforge.net/doc/pbm.html)
+}

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMWriter.java?rev=1085891&r1=1085890&r2=1085891&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMWriter.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMWriter.java
Sun Mar 27 08:46:32 2011
@@ -23,7 +23,7 @@ import java.util.Map;
 
 import org.apache.sanselan.ImageWriteException;
 
-public class PPMWriter extends PNMWriter
+public class PPMWriter extends PNMWriter implements PNMConstants
 {
     public PPMWriter(boolean RAWBITS)
     {
@@ -37,19 +37,19 @@ public class PPMWriter extends PNMWriter
         // (b1 == 0x50 && b2 == 0x36)
         os.write(0x50);
         os.write(RAWBITS ? 0x36 : 0x33);
-        os.write(' ');
+        os.write(PNM_SEPARATOR);
 
         int width = src.getWidth();
         int height = src.getHeight();
 
         os.write(("" + width).getBytes());
-        os.write(' ');
+        os.write(PNM_SEPARATOR);
 
         os.write(("" + height).getBytes());
-        os.write(' ');
+        os.write(PNM_SEPARATOR);
 
         os.write(("" + 255).getBytes()); // max component value
-        os.write('\n');
+        os.write(PNM_NEWLINE);
 
         for (int y = 0; y < height; y++)
             for (int x = 0; x < width; x++)
@@ -68,12 +68,12 @@ public class PPMWriter extends PNMWriter
                 else
                 {
                     os.write(("" + red).getBytes()); // max component value
-                    os.write(' ');
+                    os.write(PNM_SEPARATOR);
                     os.write(("" + green).getBytes()); // max component value
-                    os.write(' ');
+                    os.write(PNM_SEPARATOR);
                     os.write(("" + blue).getBytes()); // max component value
-                    os.write(' ');
+                    os.write(PNM_SEPARATOR);
                 }
             }
     }
-}
\ No newline at end of file
+}



Mime
View raw message