You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2010/09/10 18:33:42 UTC
svn commit: r995859 [17/30] - in
/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan: ./ color/
common/ common/byteSources/ common/mylzw/ formats/bmp/
formats/bmp/pixelparsers/ formats/bmp/writers/ formats/gif/ formats/ico/
formats/jpeg/ f...
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGChunktEXt.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGChunktEXt.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGChunktEXt.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGChunktEXt.java Fri Sep 10 16:33:35 2010
@@ -23,51 +23,51 @@ import org.apache.sanselan.formats.png.P
public class PNGChunktEXt extends PNGTextChunk
{
- public final String keyword, text;
+ public final String keyword, text;
- public PNGChunktEXt(int length, int chunkType, int crc, byte bytes[])
- throws ImageReadException, IOException
- {
- super(length, chunkType, crc, bytes);
- {
- int index = findNull(bytes);
- if (index < 0)
- throw new ImageReadException(
- "PNG tEXt chunk keyword is not terminated.");
-
- keyword = new String(bytes, 0, index, "ISO-8859-1");
-
- int textLength = bytes.length - (index + 1);
- text = new String(bytes, index + 1, textLength, "ISO-8859-1");
-
- if (getDebug())
- {
- System.out.println("Keyword: " + keyword);
- System.out.println("Text: " + text);
- }
-
- }
- }
-
- /**
- * @return Returns the keyword.
- */
- public String getKeyword()
- {
- return keyword;
- }
-
- /**
- * @return Returns the text.
- */
- public String getText()
- {
- return text;
- }
-
- public PngText getContents()
- {
- return new PngText.tEXt(keyword, text);
- }
+ public PNGChunktEXt(int length, int chunkType, int crc, byte bytes[])
+ throws ImageReadException, IOException
+ {
+ super(length, chunkType, crc, bytes);
+ {
+ int index = findNull(bytes);
+ if (index < 0)
+ throw new ImageReadException(
+ "PNG tEXt chunk keyword is not terminated.");
+
+ keyword = new String(bytes, 0, index, "ISO-8859-1");
+
+ int textLength = bytes.length - (index + 1);
+ text = new String(bytes, index + 1, textLength, "ISO-8859-1");
+
+ if (getDebug())
+ {
+ System.out.println("Keyword: " + keyword);
+ System.out.println("Text: " + text);
+ }
+
+ }
+ }
+
+ /**
+ * @return Returns the keyword.
+ */
+ public String getKeyword()
+ {
+ return keyword;
+ }
+
+ /**
+ * @return Returns the text.
+ */
+ public String getText()
+ {
+ return text;
+ }
+
+ public PngText getContents()
+ {
+ return new PngText.tEXt(keyword, text);
+ }
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGChunkzTXt.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGChunkzTXt.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGChunkzTXt.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGChunkzTXt.java Fri Sep 10 16:33:35 2010
@@ -26,57 +26,57 @@ import org.apache.sanselan.formats.png.P
public class PNGChunkzTXt extends PNGTextChunk
{
- public final String keyword, text;
+ public final String keyword, text;
- public PNGChunkzTXt(int length, int chunkType, int crc, byte bytes[])
- throws ImageReadException, IOException
- {
- super(length, chunkType, crc, bytes);
-
- {
- int index = findNull(bytes);
- if (index < 0)
- throw new ImageReadException(
- "PNG zTXt chunk keyword is unterminated.");
-
- keyword = new String(bytes, 0, index, "ISO-8859-1");
- index++;
-
- int compressionMethod = bytes[index++];
- if (compressionMethod != PngConstants.COMPRESSION_DEFLATE_INFLATE)
- throw new ImageReadException(
- "PNG zTXt chunk has unexpected compression method: "
- + compressionMethod);
-
- int compressedTextLength = bytes.length - index;
- byte compressedText[] = new byte[compressedTextLength];
- System.arraycopy(bytes, index, compressedText, 0,
- compressedTextLength);
-
- text = new String(new ZLibUtils().inflate(compressedText),
- "ISO-8859-1");
- }
- }
-
- /**
- * @return Returns the keyword.
- */
- public String getKeyword()
- {
- return keyword;
- }
-
- /**
- * @return Returns the text.
- */
- public String getText()
- {
- return text;
- }
-
- public PngText getContents()
- {
- return new PngText.zTXt(keyword, text);
- }
+ public PNGChunkzTXt(int length, int chunkType, int crc, byte bytes[])
+ throws ImageReadException, IOException
+ {
+ super(length, chunkType, crc, bytes);
+
+ {
+ int index = findNull(bytes);
+ if (index < 0)
+ throw new ImageReadException(
+ "PNG zTXt chunk keyword is unterminated.");
+
+ keyword = new String(bytes, 0, index, "ISO-8859-1");
+ index++;
+
+ int compressionMethod = bytes[index++];
+ if (compressionMethod != PngConstants.COMPRESSION_DEFLATE_INFLATE)
+ throw new ImageReadException(
+ "PNG zTXt chunk has unexpected compression method: "
+ + compressionMethod);
+
+ int compressedTextLength = bytes.length - index;
+ byte compressedText[] = new byte[compressedTextLength];
+ System.arraycopy(bytes, index, compressedText, 0,
+ compressedTextLength);
+
+ text = new String(new ZLibUtils().inflate(compressedText),
+ "ISO-8859-1");
+ }
+ }
+
+ /**
+ * @return Returns the keyword.
+ */
+ public String getKeyword()
+ {
+ return keyword;
+ }
+
+ /**
+ * @return Returns the text.
+ */
+ public String getText()
+ {
+ return text;
+ }
+
+ public PngText getContents()
+ {
+ return new PngText.zTXt(keyword, text);
+ }
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGTextChunk.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGTextChunk.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGTextChunk.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGTextChunk.java Fri Sep 10 16:33:35 2010
@@ -23,17 +23,17 @@ import org.apache.sanselan.formats.png.P
public abstract class PNGTextChunk extends PNGChunk
{
- public PNGTextChunk(int Length, int ChunkType, int CRC, byte bytes[])
- throws IOException
- {
- super(Length, ChunkType, CRC, bytes);
+ public PNGTextChunk(int Length, int ChunkType, int CRC, byte bytes[])
+ throws IOException
+ {
+ super(Length, ChunkType, CRC, bytes);
- }
+ }
- public abstract String getKeyword();
+ public abstract String getKeyword();
- public abstract String getText();
+ public abstract String getText();
- public abstract PngText getContents();
+ public abstract PngText getContents();
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilter.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilter.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilter.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilter.java Fri Sep 10 16:33:35 2010
@@ -22,6 +22,6 @@ import org.apache.sanselan.ImageReadExce
public abstract class ScanlineFilter
{
- public abstract void unfilter(byte src[], byte dst[], byte up[])
- throws ImageReadException, IOException;
+ public abstract void unfilter(byte src[], byte dst[], byte up[])
+ throws ImageReadException, IOException;
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterAverage.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterAverage.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterAverage.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterAverage.java Fri Sep 10 16:33:35 2010
@@ -22,32 +22,32 @@ import org.apache.sanselan.ImageReadExce
public class ScanlineFilterAverage extends ScanlineFilter
{
- private final int BytesPerPixel;
+ private final int BytesPerPixel;
- public ScanlineFilterAverage(int BytesPerPixel)
- {
- this.BytesPerPixel = BytesPerPixel;
- }
-
- public void unfilter(byte src[], byte dst[], byte up[])
- throws ImageReadException, IOException
- {
- for (int i = 0; i < src.length; i++)
- {
- int Raw = 0;
- int prev_index = i - BytesPerPixel;
- if (prev_index >= 0)
- Raw = dst[prev_index];
-
- int Prior = 0;
- if (up != null)
- Prior = up[i];
-
- int Average = ((0xff & Raw) + (0xff & Prior)) / 2;
-
- dst[i] = (byte) ((src[i] + Average) % 256);
- // dst[i] = src[i];
- // dst[i] = (byte) 255;
- }
- }
+ public ScanlineFilterAverage(int BytesPerPixel)
+ {
+ this.BytesPerPixel = BytesPerPixel;
+ }
+
+ public void unfilter(byte src[], byte dst[], byte up[])
+ throws ImageReadException, IOException
+ {
+ for (int i = 0; i < src.length; i++)
+ {
+ int Raw = 0;
+ int prev_index = i - BytesPerPixel;
+ if (prev_index >= 0)
+ Raw = dst[prev_index];
+
+ int Prior = 0;
+ if (up != null)
+ Prior = up[i];
+
+ int Average = ((0xff & Raw) + (0xff & Prior)) / 2;
+
+ dst[i] = (byte) ((src[i] + Average) % 256);
+ // dst[i] = src[i];
+ // dst[i] = (byte) 255;
+ }
+ }
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterNone.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterNone.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterNone.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterNone.java Fri Sep 10 16:33:35 2010
@@ -22,12 +22,12 @@ import org.apache.sanselan.ImageReadExce
public class ScanlineFilterNone extends ScanlineFilter
{
- public void unfilter(byte src[], byte dst[], byte up[])
- throws ImageReadException, IOException
- {
- for (int i = 0; i < src.length; i++)
- {
- dst[i] = src[i];
- }
- }
+ public void unfilter(byte src[], byte dst[], byte up[])
+ throws ImageReadException, IOException
+ {
+ for (int i = 0; i < src.length; i++)
+ {
+ dst[i] = src[i];
+ }
+ }
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterPaeth.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterPaeth.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterPaeth.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterPaeth.java Fri Sep 10 16:33:35 2010
@@ -22,58 +22,58 @@ import org.apache.sanselan.ImageReadExce
public class ScanlineFilterPaeth extends ScanlineFilter
{
- private final int BytesPerPixel;
+ private final int BytesPerPixel;
- public ScanlineFilterPaeth(int BytesPerPixel)
- {
- this.BytesPerPixel = BytesPerPixel;
- }
-
- private int PaethPredictor(int a, int b, int c)
- {
- // ; a = left, b = above, c = upper left
- int p = a + b - c; // ; initial estimate
- int pa = Math.abs(p - a); // ; distances to a, b, c
- int pb = Math.abs(p - b);
- int pc = Math.abs(p - c);
- // ; return nearest of a,b,c,
- // ; breaking ties in order a,b,c.
- if ((pa <= pb) && (pa <= pc))
- return a;
- else if (pb <= pc)
- return b;
- else
- return c;
- }
-
- public void unfilter(byte src[], byte dst[], byte up[])
- throws ImageReadException, IOException
- {
- for (int i = 0; i < src.length; i++)
- {
- int left = 0;
- int prev_index = i - BytesPerPixel;
- if (prev_index >= 0)
- left = dst[prev_index];
-
- int above = 0;
- if (up != null)
- above = up[i];
- // above = 255;
-
- int upperleft = 0;
- if ((prev_index >= 0) && (up != null))
- upperleft = up[prev_index];
- // upperleft = 255;
-
- int PaethPredictor = PaethPredictor(0xff & left, 0xff & above,
- 0xff & upperleft);
-
- dst[i] = (byte) ((src[i] + PaethPredictor) % 256);
- // dst[i] = (byte) ((src[i] + PaethPredictor) );
- // dst[i] = src[i];
-
- // dst[i] = (byte) 0;
- }
- }
+ public ScanlineFilterPaeth(int BytesPerPixel)
+ {
+ this.BytesPerPixel = BytesPerPixel;
+ }
+
+ private int PaethPredictor(int a, int b, int c)
+ {
+ // ; a = left, b = above, c = upper left
+ int p = a + b - c; // ; initial estimate
+ int pa = Math.abs(p - a); // ; distances to a, b, c
+ int pb = Math.abs(p - b);
+ int pc = Math.abs(p - c);
+ // ; return nearest of a,b,c,
+ // ; breaking ties in order a,b,c.
+ if ((pa <= pb) && (pa <= pc))
+ return a;
+ else if (pb <= pc)
+ return b;
+ else
+ return c;
+ }
+
+ public void unfilter(byte src[], byte dst[], byte up[])
+ throws ImageReadException, IOException
+ {
+ for (int i = 0; i < src.length; i++)
+ {
+ int left = 0;
+ int prev_index = i - BytesPerPixel;
+ if (prev_index >= 0)
+ left = dst[prev_index];
+
+ int above = 0;
+ if (up != null)
+ above = up[i];
+ // above = 255;
+
+ int upperleft = 0;
+ if ((prev_index >= 0) && (up != null))
+ upperleft = up[prev_index];
+ // upperleft = 255;
+
+ int PaethPredictor = PaethPredictor(0xff & left, 0xff & above,
+ 0xff & upperleft);
+
+ dst[i] = (byte) ((src[i] + PaethPredictor) % 256);
+ // dst[i] = (byte) ((src[i] + PaethPredictor) );
+ // dst[i] = src[i];
+
+ // dst[i] = (byte) 0;
+ }
+ }
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterSub.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterSub.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterSub.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterSub.java Fri Sep 10 16:33:35 2010
@@ -22,29 +22,29 @@ import org.apache.sanselan.ImageReadExce
public class ScanlineFilterSub extends ScanlineFilter
{
- private final int BytesPerPixel;
+ private final int BytesPerPixel;
- public ScanlineFilterSub(int BytesPerPixel)
- {
- this.BytesPerPixel = BytesPerPixel;
- }
+ public ScanlineFilterSub(int BytesPerPixel)
+ {
+ this.BytesPerPixel = BytesPerPixel;
+ }
- public void unfilter(byte src[], byte dst[], byte up[])
- throws ImageReadException, IOException
- {
- for (int i = 0; i < src.length; i++)
- {
- int prev_index = i - BytesPerPixel;
- if (prev_index >= 0)
- dst[i] = (byte) ((src[i] + dst[prev_index]) % 256);
- // dst[i] = 0xff & (src[i] + src[prev_index]);
- else
- dst[i] = src[i];
+ public void unfilter(byte src[], byte dst[], byte up[])
+ throws ImageReadException, IOException
+ {
+ for (int i = 0; i < src.length; i++)
+ {
+ int prev_index = i - BytesPerPixel;
+ if (prev_index >= 0)
+ dst[i] = (byte) ((src[i] + dst[prev_index]) % 256);
+ // dst[i] = 0xff & (src[i] + src[prev_index]);
+ else
+ dst[i] = src[i];
- // if(i<10)
- // System.out.println("\t" + i + ": " + dst[i] + " (" + src[i] + ", " + prev_index + ")");
+ // if(i<10)
+ // System.out.println("\t" + i + ": " + dst[i] + " (" + src[i] + ", " + prev_index + ")");
- // dst[i] = src[i];
- }
- }
+ // dst[i] = src[i];
+ }
+ }
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterUp.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterUp.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterUp.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterUp.java Fri Sep 10 16:33:35 2010
@@ -22,30 +22,30 @@ import org.apache.sanselan.ImageReadExce
public class ScanlineFilterUp extends ScanlineFilter
{
- private final int BytesPerPixel;
+ private final int BytesPerPixel;
- public ScanlineFilterUp(int BytesPerPixel)
- {
- this.BytesPerPixel = BytesPerPixel;
- }
+ public ScanlineFilterUp(int BytesPerPixel)
+ {
+ this.BytesPerPixel = BytesPerPixel;
+ }
- public void unfilter(byte src[], byte dst[], byte up[])
- throws ImageReadException, IOException
- {
- for (int i = 0; i < src.length; i++)
- {
- // byte b;
+ public void unfilter(byte src[], byte dst[], byte up[])
+ throws ImageReadException, IOException
+ {
+ for (int i = 0; i < src.length; i++)
+ {
+ // byte b;
- if (up != null)
- dst[i] = (byte) ((src[i] + up[i]) % 256);
- else
- dst[i] = src[i];
+ if (up != null)
+ dst[i] = (byte) ((src[i] + up[i]) % 256);
+ else
+ dst[i] = src[i];
- // if(i<10)
- // System.out.println("\t" + i + ": " + dst[i]);
- // dst[i] = b;
- // dst[i] = src[i];
- // dst[i] = (byte) 0;
- }
- }
+ // if(i<10)
+ // System.out.println("\t" + i + ": " + dst[i]);
+ // dst[i] = b;
+ // dst[i] = src[i];
+ // dst[i] = (byte) 0;
+ }
+ }
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/FileInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/FileInfo.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/FileInfo.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/FileInfo.java Fri Sep 10 16:33:35 2010
@@ -25,85 +25,85 @@ import org.apache.sanselan.ImageFormat;
public abstract class FileInfo
{
- protected final int width, height;
- protected final boolean RAWBITS;
+ protected final int width, height;
+ protected final boolean RAWBITS;
- public FileInfo(int width, int height, boolean RAWBITS)
- {
- this.width = width;
- this.height = height;
- this.RAWBITS = RAWBITS;
- }
-
- public abstract int getNumComponents();
-
- public abstract int getBitDepth();
-
- public abstract ImageFormat getImageType();
-
- public abstract String getImageTypeDescription();
-
- public abstract String getMIMEType();
-
- public abstract int getColorType();
-
- public abstract int getRGB(WhiteSpaceReader wsr) throws IOException;
-
- public abstract int getRGB(InputStream is) throws IOException;
-
- protected void newline()
- {
- // do nothing by default.
- }
-
- public void readImage(BufferedImage bi, InputStream is) throws IOException
- {
- // is = new BufferedInputStream(is);
- // int count = 0;
- //
- // try
- // {
- DataBuffer buffer = bi.getRaster().getDataBuffer();
-
- if (!RAWBITS)
- {
- WhiteSpaceReader wsr = new WhiteSpaceReader(is);
-
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)
- {
- int rgb = getRGB(wsr);
-
- buffer.setElem(y * width + x, rgb);
- // count++;
- }
- newline();
- }
- } else
- {
- for (int y = 0; y < height; y++)
- {
- // System.out.println("y: " + y);
- for (int x = 0; x < width; x++)
- {
- int rgb = getRGB(is);
- buffer.setElem(y * width + x, rgb);
- // count++;
- }
- newline();
- }
- }
- // }
- // finally
- // {
- // System.out.println("count: " + count);
- // dump();
- // }
- }
+ public FileInfo(int width, int height, boolean RAWBITS)
+ {
+ this.width = width;
+ this.height = height;
+ this.RAWBITS = RAWBITS;
+ }
+
+ public abstract int getNumComponents();
+
+ public abstract int getBitDepth();
+
+ public abstract ImageFormat getImageType();
+
+ public abstract String getImageTypeDescription();
+
+ public abstract String getMIMEType();
+
+ public abstract int getColorType();
+
+ public abstract int getRGB(WhiteSpaceReader wsr) throws IOException;
+
+ public abstract int getRGB(InputStream is) throws IOException;
+
+ protected void newline()
+ {
+ // do nothing by default.
+ }
+
+ public void readImage(BufferedImage bi, InputStream is) throws IOException
+ {
+ // is = new BufferedInputStream(is);
+ // int count = 0;
+ //
+ // try
+ // {
+ DataBuffer buffer = bi.getRaster().getDataBuffer();
+
+ if (!RAWBITS)
+ {
+ WhiteSpaceReader wsr = new WhiteSpaceReader(is);
+
+ for (int y = 0; y < height; y++)
+ {
+ for (int x = 0; x < width; x++)
+ {
+ int rgb = getRGB(wsr);
+
+ buffer.setElem(y * width + x, rgb);
+ // count++;
+ }
+ newline();
+ }
+ } else
+ {
+ for (int y = 0; y < height; y++)
+ {
+ // System.out.println("y: " + y);
+ for (int x = 0; x < width; x++)
+ {
+ int rgb = getRGB(is);
+ buffer.setElem(y * width + x, rgb);
+ // count++;
+ }
+ newline();
+ }
+ }
+ // }
+ // finally
+ // {
+ // System.out.println("count: " + count);
+ // dump();
+ // }
+ }
- public void dump()
- {
+ public void dump()
+ {
- }
+ }
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMFileInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMFileInfo.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMFileInfo.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMFileInfo.java Fri Sep 10 16:33:35 2010
@@ -24,81 +24,81 @@ import org.apache.sanselan.ImageInfo;
public class PBMFileInfo extends FileInfo
{
- public PBMFileInfo(int width, int height, boolean RAWBITS)
- {
- super(width, height, RAWBITS);
- }
-
- public int getNumComponents()
- {
- return 1;
- }
-
- public int getBitDepth()
- {
- return 1;
- }
-
- public ImageFormat getImageType()
- {
- return ImageFormat.IMAGE_FORMAT_PBM;
- }
-
- public int getColorType()
- {
- return ImageInfo.COLOR_TYPE_BW;
- }
-
- public String getImageTypeDescription()
- {
- return "PBM: portable bitmap fileformat";
- }
-
- public String getMIMEType()
- {
- return "image/x-portable-bitmap";
- }
-
- protected void newline()
- {
- bitcache = 0;
- bits_in_cache = 0;
- }
-
-
- private int bitcache = 0;
- private int bits_in_cache = 0;
-
- public int getRGB(InputStream is) throws IOException
- {
- if (bits_in_cache < 1)
- {
- int bits = is.read();
- if (bits < 0)
- throw new IOException("PBM: Unexpected EOF");
- bitcache = 0xff & bits;
- bits_in_cache += 8;
- }
-
- int bit = 0x1 & (bitcache >> 7);
- bitcache <<= 1;
- bits_in_cache--;
-
- if (bit == 0)
- return 0xffffffff;
- if (bit == 1)
- return 0xff000000;
- throw new IOException("PBM: bad bit: " + bit);
- }
-
- public int getRGB(WhiteSpaceReader wsr) throws IOException
- {
- int bit = Integer.parseInt(wsr.readtoWhiteSpace());
- if (bit == 0)
- return 0xff000000;
- if (bit == 1)
- return 0xffffffff;
- throw new IOException("PBM: bad bit: " + bit);
- }
+ public PBMFileInfo(int width, int height, boolean RAWBITS)
+ {
+ super(width, height, RAWBITS);
+ }
+
+ public int getNumComponents()
+ {
+ return 1;
+ }
+
+ public int getBitDepth()
+ {
+ return 1;
+ }
+
+ public ImageFormat getImageType()
+ {
+ return ImageFormat.IMAGE_FORMAT_PBM;
+ }
+
+ public int getColorType()
+ {
+ return ImageInfo.COLOR_TYPE_BW;
+ }
+
+ public String getImageTypeDescription()
+ {
+ return "PBM: portable bitmap fileformat";
+ }
+
+ public String getMIMEType()
+ {
+ return "image/x-portable-bitmap";
+ }
+
+ protected void newline()
+ {
+ bitcache = 0;
+ bits_in_cache = 0;
+ }
+
+
+ private int bitcache = 0;
+ private int bits_in_cache = 0;
+
+ public int getRGB(InputStream is) throws IOException
+ {
+ if (bits_in_cache < 1)
+ {
+ int bits = is.read();
+ if (bits < 0)
+ throw new IOException("PBM: Unexpected EOF");
+ bitcache = 0xff & bits;
+ bits_in_cache += 8;
+ }
+
+ int bit = 0x1 & (bitcache >> 7);
+ bitcache <<= 1;
+ bits_in_cache--;
+
+ if (bit == 0)
+ return 0xffffffff;
+ if (bit == 1)
+ return 0xff000000;
+ throw new IOException("PBM: bad bit: " + bit);
+ }
+
+ public int getRGB(WhiteSpaceReader wsr) throws IOException
+ {
+ int bit = Integer.parseInt(wsr.readtoWhiteSpace());
+ if (bit == 0)
+ return 0xff000000;
+ if (bit == 1)
+ return 0xffffffff;
+ throw new IOException("PBM: bad bit: " + bit);
+ }
}
\ No newline at end of file
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=995859&r1=995858&r2=995859&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 Fri Sep 10 16:33:35 2010
@@ -25,69 +25,69 @@ import org.apache.sanselan.ImageWriteExc
public class PBMWriter extends PNMWriter implements PNMConstants
{
- public PBMWriter(boolean RAWBITS)
- {
- super(RAWBITS);
- }
-
- public void writeImage(BufferedImage src, OutputStream os, Map params)
- throws ImageWriteException, IOException
- {
- os.write(PNM_PREFIX_BYTE);
- os.write(RAWBITS ? PBM_RAW_CODE : PBM_TEXT_CODE);
- os.write(PNM_SEPARATOR);
-
- int width = src.getWidth();
- int height = src.getHeight();
-
- os.write(("" + width).getBytes());
- os.write(PNM_SEPARATOR);
-
- os.write(("" + height).getBytes());
- os.write(PNM_SEPARATOR);
-
- int bitcache = 0;
- int bits_in_cache = 0;
-
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)
- {
- int argb = src.getRGB(x, y);
- int red = 0xff & (argb >> 16);
- int green = 0xff & (argb >> 8);
- int blue = 0xff & (argb >> 0);
- int sample = (red + green + blue) / 3;
- if (sample > 127)
- sample = 0;
- else
- sample = 1;
-
- if (RAWBITS)
- {
- bitcache = (bitcache << 1) | (0x1 & sample);
- bits_in_cache++;
-
- if (bits_in_cache >= 8)
- {
- os.write((byte) bitcache);
- bitcache = 0;
- bits_in_cache = 0;
- }
- } else
- {
- os.write(("" + sample).getBytes()); // max component value
- os.write(PNM_SEPARATOR);
- }
- }
-
- if ((RAWBITS) && (bits_in_cache > 0))
- {
- bitcache = bitcache << (8-bits_in_cache);
- os.write((byte) bitcache);
- bitcache = 0;
- bits_in_cache = 0;
- }
- }
- }
+ public PBMWriter(boolean RAWBITS)
+ {
+ super(RAWBITS);
+ }
+
+ public void writeImage(BufferedImage src, OutputStream os, Map params)
+ throws ImageWriteException, IOException
+ {
+ os.write(PNM_PREFIX_BYTE);
+ os.write(RAWBITS ? PBM_RAW_CODE : PBM_TEXT_CODE);
+ os.write(PNM_SEPARATOR);
+
+ int width = src.getWidth();
+ int height = src.getHeight();
+
+ os.write(("" + width).getBytes());
+ os.write(PNM_SEPARATOR);
+
+ os.write(("" + height).getBytes());
+ os.write(PNM_SEPARATOR);
+
+ int bitcache = 0;
+ int bits_in_cache = 0;
+
+ for (int y = 0; y < height; y++)
+ {
+ for (int x = 0; x < width; x++)
+ {
+ int argb = src.getRGB(x, y);
+ int red = 0xff & (argb >> 16);
+ int green = 0xff & (argb >> 8);
+ int blue = 0xff & (argb >> 0);
+ int sample = (red + green + blue) / 3;
+ if (sample > 127)
+ sample = 0;
+ else
+ sample = 1;
+
+ if (RAWBITS)
+ {
+ bitcache = (bitcache << 1) | (0x1 & sample);
+ bits_in_cache++;
+
+ if (bits_in_cache >= 8)
+ {
+ os.write((byte) bitcache);
+ bitcache = 0;
+ bits_in_cache = 0;
+ }
+ } else
+ {
+ os.write(("" + sample).getBytes()); // max component value
+ os.write(PNM_SEPARATOR);
+ }
+ }
+
+ if ((RAWBITS) && (bits_in_cache > 0))
+ {
+ bitcache = bitcache << (8-bits_in_cache);
+ os.write((byte) bitcache);
+ bitcache = 0;
+ bits_in_cache = 0;
+ }
+ }
+ }
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMFileInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMFileInfo.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMFileInfo.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMFileInfo.java Fri Sep 10 16:33:35 2010
@@ -24,69 +24,69 @@ import org.apache.sanselan.ImageInfo;
public class PGMFileInfo extends FileInfo
{
- private final int max; // TODO: handle max
+ private final int max; // TODO: handle max
- public PGMFileInfo(int width, int height, boolean RAWBITS, int max)
- {
- super(width, height, RAWBITS);
-
- this.max = max;
- }
-
- public int getNumComponents()
- {
- return 1;
- }
-
- public int getBitDepth()
- {
- return 8;
- }
-
- public ImageFormat getImageType()
- {
- return ImageFormat.IMAGE_FORMAT_PPM;
- }
-
- public String getImageTypeDescription()
- {
- return "PGM: portable pixmap file format";
- }
-
- public String getMIMEType()
- {
- return "image/x-portable-pixmap";
- }
-
- public int getColorType()
- {
- return ImageInfo.COLOR_TYPE_RGB;
- }
-
- public int getRGB(InputStream is) throws IOException
- {
- int sample = is.read();
- if (sample < 0)
- throw new IOException("PGM: Unexpected EOF");
-
- int alpha = 0xff;
-
- int rgb = ((0xff & alpha) << 24) | ((0xff & sample) << 16)
- | ((0xff & sample) << 8) | ((0xff & sample) << 0);
-
- return rgb;
- }
-
- public int getRGB(WhiteSpaceReader wsr) throws IOException
- {
- int sample = Integer.parseInt(wsr.readtoWhiteSpace());
+ public PGMFileInfo(int width, int height, boolean RAWBITS, int max)
+ {
+ super(width, height, RAWBITS);
+
+ this.max = max;
+ }
+
+ public int getNumComponents()
+ {
+ return 1;
+ }
+
+ public int getBitDepth()
+ {
+ return 8;
+ }
+
+ public ImageFormat getImageType()
+ {
+ return ImageFormat.IMAGE_FORMAT_PPM;
+ }
+
+ public String getImageTypeDescription()
+ {
+ return "PGM: portable pixmap file format";
+ }
+
+ public String getMIMEType()
+ {
+ return "image/x-portable-pixmap";
+ }
+
+ public int getColorType()
+ {
+ return ImageInfo.COLOR_TYPE_RGB;
+ }
+
+ public int getRGB(InputStream is) throws IOException
+ {
+ int sample = is.read();
+ if (sample < 0)
+ throw new IOException("PGM: Unexpected EOF");
+
+ int alpha = 0xff;
+
+ int rgb = ((0xff & alpha) << 24) | ((0xff & sample) << 16)
+ | ((0xff & sample) << 8) | ((0xff & sample) << 0);
+
+ return rgb;
+ }
+
+ public int getRGB(WhiteSpaceReader wsr) throws IOException
+ {
+ int sample = Integer.parseInt(wsr.readtoWhiteSpace());
- int alpha = 0xff;
+ int alpha = 0xff;
- int rgb = ((0xff & alpha) << 24) | ((0xff & sample) << 16)
- | ((0xff & sample) << 8) | ((0xff & sample) << 0);
+ int rgb = ((0xff & alpha) << 24) | ((0xff & sample) << 16)
+ | ((0xff & sample) << 8) | ((0xff & sample) << 0);
- return rgb;
- }
+ return rgb;
+ }
}
\ 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=995859&r1=995858&r2=995859&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 Fri Sep 10 16:33:35 2010
@@ -25,51 +25,51 @@ import org.apache.sanselan.ImageWriteExc
public class PGMWriter extends PNMWriter
{
- public PGMWriter(boolean RAWBITS)
- {
- super(RAWBITS);
- }
-
- public void writeImage(BufferedImage src, OutputStream os, Map params)
- throws ImageWriteException, IOException
- {
- // System.out.println
- // (b1 == 0x50 && b2 == 0x36)
- os.write(0x50);
- os.write(RAWBITS ? 0x35 : 0x32);
- os.write(' ');
-
- int width = src.getWidth();
- int height = src.getHeight();
-
- os.write(("" + width).getBytes());
- os.write(' ');
-
- os.write(("" + height).getBytes());
- os.write(' ');
-
- os.write(("" + 255).getBytes()); // max component value
- os.write('\n');
-
- for (int y = 0; y < height; y++)
- for (int x = 0; x < width; x++)
- {
- int argb = src.getRGB(x, y);
- int red = 0xff & (argb >> 16);
- int green = 0xff & (argb >> 8);
- int blue = 0xff & (argb >> 0);
- int sample = (red + green + blue) / 3;
-
- if (RAWBITS)
- {
- os.write((byte) sample);
- }
- else
- {
- os.write(("" + sample).getBytes()); // max component value
- os.write(' ');
- }
- }
- }
+ public PGMWriter(boolean RAWBITS)
+ {
+ super(RAWBITS);
+ }
+
+ public void writeImage(BufferedImage src, OutputStream os, Map params)
+ throws ImageWriteException, IOException
+ {
+ // System.out.println
+ // (b1 == 0x50 && b2 == 0x36)
+ os.write(0x50);
+ os.write(RAWBITS ? 0x35 : 0x32);
+ os.write(' ');
+
+ int width = src.getWidth();
+ int height = src.getHeight();
+
+ os.write(("" + width).getBytes());
+ os.write(' ');
+
+ os.write(("" + height).getBytes());
+ os.write(' ');
+
+ os.write(("" + 255).getBytes()); // max component value
+ os.write('\n');
+
+ for (int y = 0; y < height; y++)
+ for (int x = 0; x < width; x++)
+ {
+ int argb = src.getRGB(x, y);
+ int red = 0xff & (argb >> 16);
+ int green = 0xff & (argb >> 8);
+ int blue = 0xff & (argb >> 0);
+ int sample = (red + green + blue) / 3;
+
+ if (RAWBITS)
+ {
+ os.write((byte) sample);
+ }
+ else
+ {
+ os.write(("" + sample).getBytes()); // max component value
+ os.write(' ');
+ }
+ }
+ }
}
\ 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=995859&r1=995858&r2=995859&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 Fri Sep 10 16:33:35 2010
@@ -18,15 +18,15 @@ package org.apache.sanselan.formats.pnm;
public interface PNMConstants
{
- public static final byte PNM_PREFIX_BYTE = 0x50; // P
+ public static final byte PNM_PREFIX_BYTE = 0x50; // P
- public static final byte PBM_TEXT_CODE = 0x31; // Textual Bitmap
- public static final byte PGM_TEXT_CODE = 0x32; // Textual GrayMap
- public static final byte PPM_TEXT_CODE = 0x33; // Textual Pixmap
- 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 PBM_TEXT_CODE = 0x31; // Textual Bitmap
+ public static final byte PGM_TEXT_CODE = 0x32; // Textual GrayMap
+ public static final byte PPM_TEXT_CODE = 0x33; // Textual Pixmap
+ 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 PNM_SEPARATOR = 0x20; // Space
+ public static final byte PNM_SEPARATOR = 0x20; // Space
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMImageParser.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMImageParser.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMImageParser.java Fri Sep 10 16:33:35 2010
@@ -39,325 +39,325 @@ import org.apache.sanselan.util.Debug;
public class PNMImageParser extends ImageParser implements PNMConstants
{
- public PNMImageParser()
- {
- super.setByteOrder(BYTE_ORDER_LSB);
- // setDebug(true);
- }
-
- public String getName()
- {
- return "Pbm-Custom";
- }
-
- public String getDefaultExtension()
- {
- return DEFAULT_EXTENSION;
- }
-
- private static final String DEFAULT_EXTENSION = ".pnm";
-
- private static final String ACCEPTED_EXTENSIONS[] = { ".pbm", ".pgm",
- ".ppm", ".pnm", };
-
- protected String[] getAcceptedExtensions()
- {
- return ACCEPTED_EXTENSIONS;
- }
-
- protected ImageFormat[] getAcceptedTypes()
- {
- return new ImageFormat[] { ImageFormat.IMAGE_FORMAT_PBM, //
- ImageFormat.IMAGE_FORMAT_PGM, //
- ImageFormat.IMAGE_FORMAT_PPM, //
- ImageFormat.IMAGE_FORMAT_PNM, };
- }
-
- private FileInfo readHeader(InputStream is) throws ImageReadException,
- IOException
- {
- 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.");
-
- 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);
- } else
- throw new ImageReadException("PNM file has invalid header.");
- }
-
- private FileInfo readHeader(ByteSource byteSource)
- throws ImageReadException, IOException
- {
- InputStream is = null;
-
- try
- {
- is = byteSource.getInputStream();
-
- return readHeader(is);
- } finally
- {
- try
- {
- if (is != null) {
- is.close();
- }
- } catch (Exception e)
- {
- Debug.debug(e);
- }
- }
- }
-
- public byte[] getICCProfileBytes(ByteSource byteSource, Map params)
- throws ImageReadException, IOException
- {
- return null;
- }
-
- public Dimension getImageSize(ByteSource byteSource, Map params)
- throws ImageReadException, IOException
- {
- FileInfo info = readHeader(byteSource);
-
- if (info == null)
- throw new ImageReadException("PNM: Couldn't read Header");
-
- return new Dimension(info.width, info.height);
- }
-
- public byte[] embedICCProfile(byte image[], byte profile[])
- {
- return null;
- }
-
- public boolean embedICCProfile(File src, File dst, byte profile[])
- {
- return false;
- }
-
- public IImageMetadata getMetadata(ByteSource byteSource, Map params)
- throws ImageReadException, IOException
- {
- return null;
- }
-
- public ImageInfo getImageInfo(ByteSource byteSource, Map params)
- throws ImageReadException, IOException
- {
- FileInfo info = readHeader(byteSource);
-
- if (info == null)
- throw new ImageReadException("PNM: Couldn't read Header");
-
- ArrayList Comments = new ArrayList();
-
- int BitsPerPixel = info.getBitDepth() * info.getNumComponents();
- ImageFormat Format = info.getImageType();
- String FormatName = info.getImageTypeDescription();
- String MimeType = info.getMIMEType();
- int NumberOfImages = 1;
- boolean isProgressive = false;
-
- // boolean isProgressive = (fPNGChunkIHDR.InterlaceMethod != 0);
- //
- int PhysicalWidthDpi = 72;
- float PhysicalWidthInch = (float) ((double) info.width / (double) PhysicalWidthDpi);
- int PhysicalHeightDpi = 72;
- float PhysicalHeightInch = (float) ((double) info.height / (double) PhysicalHeightDpi);
-
- String FormatDetails = info.getImageTypeDescription();
-
- boolean isTransparent = false;
- boolean usesPalette = false;
-
- int ColorType = info.getColorType();
- String compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_NONE;
-
- ImageInfo result = new ImageInfo(FormatDetails, BitsPerPixel, Comments,
- Format, FormatName, info.height, MimeType, NumberOfImages,
- PhysicalHeightDpi, PhysicalHeightInch, PhysicalWidthDpi,
- PhysicalWidthInch, info.width, isProgressive, isTransparent,
- usesPalette, ColorType, compressionAlgorithm);
-
- return result;
- }
-
- public boolean dumpImageFile(PrintWriter pw, ByteSource byteSource)
- throws ImageReadException, IOException
- {
- pw.println("pnm.dumpImageFile");
-
- {
- ImageInfo imageData = getImageInfo(byteSource);
- if (imageData == null)
- return false;
-
- imageData.toString(pw, "");
- }
-
- pw.println("");
-
- return true;
- }
-
- private int[] getColorTable(byte bytes[]) throws ImageReadException,
- IOException
- {
- if ((bytes.length % 3) != 0)
- throw new ImageReadException("Bad Color Table Length: "
- + bytes.length);
- int length = bytes.length / 3;
-
- int result[] = new int[length];
-
- for (int i = 0; i < length; i++)
- {
- int red = 0xff & bytes[(i * 3) + 0];
- int green = 0xff & bytes[(i * 3) + 1];
- int blue = 0xff & bytes[(i * 3) + 2];
-
- int alpha = 0xff;
-
- int rgb = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0);
- result[i] = rgb;
- }
-
- return result;
- }
-
- public BufferedImage getBufferedImage(ByteSource byteSource, Map params)
- throws ImageReadException, IOException
- {
- InputStream is = null;
-
- try
- {
- is = byteSource.getInputStream();
-
- FileInfo info = readHeader(is);
-
- int width = info.width;
- int height = info.height;
-
- boolean hasAlpha = false;
- BufferedImage result = getBufferedImageFactory(params)
- .getColorBufferedImage(width, height, hasAlpha);
-
- info.readImage(result, is);
-
- return result;
- } finally
- {
- try
- {
- if (is != null) {
- is.close();
- }
- } catch (Exception e)
- {
- Debug.debug(e);
- }
- }
- }
-
- public static final String PARAM_KEY_PNM_RAWBITS = "PNM_RAWBITS";
- public static final String PARAM_VALUE_PNM_RAWBITS_YES = "YES";
- public static final String PARAM_VALUE_PNM_RAWBITS_NO = "NO";
-
- public void writeImage(BufferedImage src, OutputStream os, Map params)
- throws ImageWriteException, IOException
- {
- PNMWriter writer = null;
- boolean useRawbits = true;
-
- if (params != null)
- {
- Object useRawbitsParam = params.get(PARAM_KEY_PNM_RAWBITS);
- if (useRawbitsParam != null)
- {
- if (useRawbitsParam.equals(PARAM_VALUE_PNM_RAWBITS_NO))
- useRawbits = false;
- }
-
- Object subtype = params.get(PARAM_KEY_FORMAT);
- if (subtype != null)
- {
- if (subtype.equals(ImageFormat.IMAGE_FORMAT_PBM))
- writer = new PBMWriter(useRawbits);
- else if (subtype.equals(ImageFormat.IMAGE_FORMAT_PGM))
- writer = new PGMWriter(useRawbits);
- else if (subtype.equals(ImageFormat.IMAGE_FORMAT_PPM))
- writer = new PPMWriter(useRawbits);
- }
- }
-
- if (writer == null)
- writer = new PPMWriter(useRawbits);
-
- // make copy of params; we'll clear keys as we consume them.
- params = new HashMap(params);
-
- // clear format key.
- if (params.containsKey(PARAM_KEY_FORMAT))
- params.remove(PARAM_KEY_FORMAT);
-
- if (params.size() > 0)
- {
- Object firstKey = params.keySet().iterator().next();
- throw new ImageWriteException("Unknown parameter: " + firstKey);
- }
-
- writer.writeImage(src, os, params);
- }
-
- /**
- * Extracts embedded XML metadata as XML string.
- * <p>
- *
- * @param byteSource
- * File containing image data.
- * @param params
- * Map of optional parameters, defined in SanselanConstants.
- * @return Xmp Xml as String, if present. Otherwise, returns null.
- */
- public String getXmpXml(ByteSource byteSource, Map params)
- throws ImageReadException, IOException
- {
- return null;
- }
+ public PNMImageParser()
+ {
+ super.setByteOrder(BYTE_ORDER_LSB);
+ // setDebug(true);
+ }
+
+ public String getName()
+ {
+ return "Pbm-Custom";
+ }
+
+ public String getDefaultExtension()
+ {
+ return DEFAULT_EXTENSION;
+ }
+
+ private static final String DEFAULT_EXTENSION = ".pnm";
+
+ private static final String ACCEPTED_EXTENSIONS[] = { ".pbm", ".pgm",
+ ".ppm", ".pnm", };
+
+ protected String[] getAcceptedExtensions()
+ {
+ return ACCEPTED_EXTENSIONS;
+ }
+
+ protected ImageFormat[] getAcceptedTypes()
+ {
+ return new ImageFormat[] { ImageFormat.IMAGE_FORMAT_PBM, //
+ ImageFormat.IMAGE_FORMAT_PGM, //
+ ImageFormat.IMAGE_FORMAT_PPM, //
+ ImageFormat.IMAGE_FORMAT_PNM, };
+ }
+
+ private FileInfo readHeader(InputStream is) throws ImageReadException,
+ IOException
+ {
+ 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.");
+
+ 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);
+ } else
+ throw new ImageReadException("PNM file has invalid header.");
+ }
+
+ private FileInfo readHeader(ByteSource byteSource)
+ throws ImageReadException, IOException
+ {
+ InputStream is = null;
+
+ try
+ {
+ is = byteSource.getInputStream();
+
+ return readHeader(is);
+ } finally
+ {
+ try
+ {
+ if (is != null) {
+ is.close();
+ }
+ } catch (Exception e)
+ {
+ Debug.debug(e);
+ }
+ }
+ }
+
+ public byte[] getICCProfileBytes(ByteSource byteSource, Map params)
+ throws ImageReadException, IOException
+ {
+ return null;
+ }
+
+ public Dimension getImageSize(ByteSource byteSource, Map params)
+ throws ImageReadException, IOException
+ {
+ FileInfo info = readHeader(byteSource);
+
+ if (info == null)
+ throw new ImageReadException("PNM: Couldn't read Header");
+
+ return new Dimension(info.width, info.height);
+ }
+
+ public byte[] embedICCProfile(byte image[], byte profile[])
+ {
+ return null;
+ }
+
+ public boolean embedICCProfile(File src, File dst, byte profile[])
+ {
+ return false;
+ }
+
+ public IImageMetadata getMetadata(ByteSource byteSource, Map params)
+ throws ImageReadException, IOException
+ {
+ return null;
+ }
+
+ public ImageInfo getImageInfo(ByteSource byteSource, Map params)
+ throws ImageReadException, IOException
+ {
+ FileInfo info = readHeader(byteSource);
+
+ if (info == null)
+ throw new ImageReadException("PNM: Couldn't read Header");
+
+ ArrayList Comments = new ArrayList();
+
+ int BitsPerPixel = info.getBitDepth() * info.getNumComponents();
+ ImageFormat Format = info.getImageType();
+ String FormatName = info.getImageTypeDescription();
+ String MimeType = info.getMIMEType();
+ int NumberOfImages = 1;
+ boolean isProgressive = false;
+
+ // boolean isProgressive = (fPNGChunkIHDR.InterlaceMethod != 0);
+ //
+ int PhysicalWidthDpi = 72;
+ float PhysicalWidthInch = (float) ((double) info.width / (double) PhysicalWidthDpi);
+ int PhysicalHeightDpi = 72;
+ float PhysicalHeightInch = (float) ((double) info.height / (double) PhysicalHeightDpi);
+
+ String FormatDetails = info.getImageTypeDescription();
+
+ boolean isTransparent = false;
+ boolean usesPalette = false;
+
+ int ColorType = info.getColorType();
+ String compressionAlgorithm = ImageInfo.COMPRESSION_ALGORITHM_NONE;
+
+ ImageInfo result = new ImageInfo(FormatDetails, BitsPerPixel, Comments,
+ Format, FormatName, info.height, MimeType, NumberOfImages,
+ PhysicalHeightDpi, PhysicalHeightInch, PhysicalWidthDpi,
+ PhysicalWidthInch, info.width, isProgressive, isTransparent,
+ usesPalette, ColorType, compressionAlgorithm);
+
+ return result;
+ }
+
+ public boolean dumpImageFile(PrintWriter pw, ByteSource byteSource)
+ throws ImageReadException, IOException
+ {
+ pw.println("pnm.dumpImageFile");
+
+ {
+ ImageInfo imageData = getImageInfo(byteSource);
+ if (imageData == null)
+ return false;
+
+ imageData.toString(pw, "");
+ }
+
+ pw.println("");
+
+ return true;
+ }
+
+ private int[] getColorTable(byte bytes[]) throws ImageReadException,
+ IOException
+ {
+ if ((bytes.length % 3) != 0)
+ throw new ImageReadException("Bad Color Table Length: "
+ + bytes.length);
+ int length = bytes.length / 3;
+
+ int result[] = new int[length];
+
+ for (int i = 0; i < length; i++)
+ {
+ int red = 0xff & bytes[(i * 3) + 0];
+ int green = 0xff & bytes[(i * 3) + 1];
+ int blue = 0xff & bytes[(i * 3) + 2];
+
+ int alpha = 0xff;
+
+ int rgb = (alpha << 24) | (red << 16) | (green << 8) | (blue << 0);
+ result[i] = rgb;
+ }
+
+ return result;
+ }
+
+ public BufferedImage getBufferedImage(ByteSource byteSource, Map params)
+ throws ImageReadException, IOException
+ {
+ InputStream is = null;
+
+ try
+ {
+ is = byteSource.getInputStream();
+
+ FileInfo info = readHeader(is);
+
+ int width = info.width;
+ int height = info.height;
+
+ boolean hasAlpha = false;
+ BufferedImage result = getBufferedImageFactory(params)
+ .getColorBufferedImage(width, height, hasAlpha);
+
+ info.readImage(result, is);
+
+ return result;
+ } finally
+ {
+ try
+ {
+ if (is != null) {
+ is.close();
+ }
+ } catch (Exception e)
+ {
+ Debug.debug(e);
+ }
+ }
+ }
+
+ public static final String PARAM_KEY_PNM_RAWBITS = "PNM_RAWBITS";
+ public static final String PARAM_VALUE_PNM_RAWBITS_YES = "YES";
+ public static final String PARAM_VALUE_PNM_RAWBITS_NO = "NO";
+
+ public void writeImage(BufferedImage src, OutputStream os, Map params)
+ throws ImageWriteException, IOException
+ {
+ PNMWriter writer = null;
+ boolean useRawbits = true;
+
+ if (params != null)
+ {
+ Object useRawbitsParam = params.get(PARAM_KEY_PNM_RAWBITS);
+ if (useRawbitsParam != null)
+ {
+ if (useRawbitsParam.equals(PARAM_VALUE_PNM_RAWBITS_NO))
+ useRawbits = false;
+ }
+
+ Object subtype = params.get(PARAM_KEY_FORMAT);
+ if (subtype != null)
+ {
+ if (subtype.equals(ImageFormat.IMAGE_FORMAT_PBM))
+ writer = new PBMWriter(useRawbits);
+ else if (subtype.equals(ImageFormat.IMAGE_FORMAT_PGM))
+ writer = new PGMWriter(useRawbits);
+ else if (subtype.equals(ImageFormat.IMAGE_FORMAT_PPM))
+ writer = new PPMWriter(useRawbits);
+ }
+ }
+
+ if (writer == null)
+ writer = new PPMWriter(useRawbits);
+
+ // make copy of params; we'll clear keys as we consume them.
+ params = new HashMap(params);
+
+ // clear format key.
+ if (params.containsKey(PARAM_KEY_FORMAT))
+ params.remove(PARAM_KEY_FORMAT);
+
+ if (params.size() > 0)
+ {
+ Object firstKey = params.keySet().iterator().next();
+ throw new ImageWriteException("Unknown parameter: " + firstKey);
+ }
+
+ writer.writeImage(src, os, params);
+ }
+
+ /**
+ * Extracts embedded XML metadata as XML string.
+ * <p>
+ *
+ * @param byteSource
+ * File containing image data.
+ * @param params
+ * Map of optional parameters, defined in SanselanConstants.
+ * @return Xmp Xml as String, if present. Otherwise, returns null.
+ */
+ public String getXmpXml(ByteSource byteSource, Map params)
+ throws ImageReadException, IOException
+ {
+ return null;
+ }
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMWriter.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMWriter.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMWriter.java Fri Sep 10 16:33:35 2010
@@ -25,13 +25,13 @@ import org.apache.sanselan.ImageWriteExc
public abstract class PNMWriter
{
- protected final boolean RAWBITS;
+ protected final boolean RAWBITS;
- public PNMWriter(boolean RAWBITS)
- {
- this.RAWBITS = RAWBITS;
- }
+ public PNMWriter(boolean RAWBITS)
+ {
+ this.RAWBITS = RAWBITS;
+ }
- public abstract void writeImage(BufferedImage src, OutputStream os,
- Map params) throws ImageWriteException, IOException;
+ public abstract void writeImage(BufferedImage src, OutputStream os,
+ Map params) throws ImageWriteException, IOException;
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMFileInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMFileInfo.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMFileInfo.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMFileInfo.java Fri Sep 10 16:33:35 2010
@@ -24,78 +24,78 @@ import org.apache.sanselan.ImageInfo;
public class PPMFileInfo extends FileInfo
{
- private final int max; // TODO: handle max
+ private final int max; // TODO: handle max
- public PPMFileInfo(int width, int height, boolean RAWBITS, int max)
- {
- super(width, height, RAWBITS);
-
- this.max = max;
- }
-
- public int getNumComponents()
- {
- return 3;
- }
-
- public int getBitDepth()
- {
- return 8;
- }
-
- public ImageFormat getImageType()
- {
- return ImageFormat.IMAGE_FORMAT_PGM;
- }
-
- public String getImageTypeDescription()
- {
- return "PGM: portable graymap file format";
- }
-
- public String getMIMEType()
- {
- return "image/x-portable-graymap";
- }
-
- public int getColorType()
- {
- return ImageInfo.COLOR_TYPE_GRAYSCALE;
- }
-
- public int getRGB(InputStream is) throws IOException
- {
- int red = is.read();
- int green = is.read();
- int blue = is.read();
-
- if ((red < 0) || (green < 0) || (blue < 0))
- throw new IOException("PPM: Unexpected EOF");
-
- int alpha = 0xff;
-
- int rgb = ((0xff & alpha) << 24) | ((0xff & red) << 16)
- | ((0xff & green) << 8) | ((0xff & blue) << 0);
-
- return rgb;
- }
-
- public int getRGB(WhiteSpaceReader wsr) throws IOException
- {
- int red = Integer.parseInt(wsr.readtoWhiteSpace());
- int green = Integer.parseInt(wsr.readtoWhiteSpace());
- int blue = Integer.parseInt(wsr.readtoWhiteSpace());
-
- int alpha = 0xff;
-
- int rgb = ((0xff & alpha) << 24) | ((0xff & red) << 16)
- | ((0xff & green) << 8) | ((0xff & blue) << 0);
-
- return rgb;
- }
-
- public void dump()
- {
- // System.out.println("count: " + count);
- }
+ public PPMFileInfo(int width, int height, boolean RAWBITS, int max)
+ {
+ super(width, height, RAWBITS);
+
+ this.max = max;
+ }
+
+ public int getNumComponents()
+ {
+ return 3;
+ }
+
+ public int getBitDepth()
+ {
+ return 8;
+ }
+
+ public ImageFormat getImageType()
+ {
+ return ImageFormat.IMAGE_FORMAT_PGM;
+ }
+
+ public String getImageTypeDescription()
+ {
+ return "PGM: portable graymap file format";
+ }
+
+ public String getMIMEType()
+ {
+ return "image/x-portable-graymap";
+ }
+
+ public int getColorType()
+ {
+ return ImageInfo.COLOR_TYPE_GRAYSCALE;
+ }
+
+ public int getRGB(InputStream is) throws IOException
+ {
+ int red = is.read();
+ int green = is.read();
+ int blue = is.read();
+
+ if ((red < 0) || (green < 0) || (blue < 0))
+ throw new IOException("PPM: Unexpected EOF");
+
+ int alpha = 0xff;
+
+ int rgb = ((0xff & alpha) << 24) | ((0xff & red) << 16)
+ | ((0xff & green) << 8) | ((0xff & blue) << 0);
+
+ return rgb;
+ }
+
+ public int getRGB(WhiteSpaceReader wsr) throws IOException
+ {
+ int red = Integer.parseInt(wsr.readtoWhiteSpace());
+ int green = Integer.parseInt(wsr.readtoWhiteSpace());
+ int blue = Integer.parseInt(wsr.readtoWhiteSpace());
+
+ int alpha = 0xff;
+
+ int rgb = ((0xff & alpha) << 24) | ((0xff & red) << 16)
+ | ((0xff & green) << 8) | ((0xff & blue) << 0);
+
+ return rgb;
+ }
+
+ public void dump()
+ {
+ // System.out.println("count: " + count);
+ }
}
\ No newline at end of file
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=995859&r1=995858&r2=995859&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 Fri Sep 10 16:33:35 2010
@@ -25,55 +25,55 @@ import org.apache.sanselan.ImageWriteExc
public class PPMWriter extends PNMWriter
{
- public PPMWriter(boolean RAWBITS)
- {
- super(RAWBITS);
- }
-
- public void writeImage(BufferedImage src, OutputStream os, Map params)
- throws ImageWriteException, IOException
- {
- // System.out.println
- // (b1 == 0x50 && b2 == 0x36)
- os.write(0x50);
- os.write(RAWBITS ? 0x36 : 0x33);
- os.write(' ');
-
- int width = src.getWidth();
- int height = src.getHeight();
-
- os.write(("" + width).getBytes());
- os.write(' ');
-
- os.write(("" + height).getBytes());
- os.write(' ');
-
- os.write(("" + 255).getBytes()); // max component value
- os.write('\n');
-
- for (int y = 0; y < height; y++)
- for (int x = 0; x < width; x++)
- {
- int argb = src.getRGB(x, y);
- int red = 0xff & (argb >> 16);
- int green = 0xff & (argb >> 8);
- int blue = 0xff & (argb >> 0);
-
- if (RAWBITS)
- {
- os.write((byte) red);
- os.write((byte) green);
- os.write((byte) blue);
- }
- else
- {
- os.write(("" + red).getBytes()); // max component value
- os.write(' ');
- os.write(("" + green).getBytes()); // max component value
- os.write(' ');
- os.write(("" + blue).getBytes()); // max component value
- os.write(' ');
- }
- }
- }
+ public PPMWriter(boolean RAWBITS)
+ {
+ super(RAWBITS);
+ }
+
+ public void writeImage(BufferedImage src, OutputStream os, Map params)
+ throws ImageWriteException, IOException
+ {
+ // System.out.println
+ // (b1 == 0x50 && b2 == 0x36)
+ os.write(0x50);
+ os.write(RAWBITS ? 0x36 : 0x33);
+ os.write(' ');
+
+ int width = src.getWidth();
+ int height = src.getHeight();
+
+ os.write(("" + width).getBytes());
+ os.write(' ');
+
+ os.write(("" + height).getBytes());
+ os.write(' ');
+
+ os.write(("" + 255).getBytes()); // max component value
+ os.write('\n');
+
+ for (int y = 0; y < height; y++)
+ for (int x = 0; x < width; x++)
+ {
+ int argb = src.getRGB(x, y);
+ int red = 0xff & (argb >> 16);
+ int green = 0xff & (argb >> 8);
+ int blue = 0xff & (argb >> 0);
+
+ if (RAWBITS)
+ {
+ os.write((byte) red);
+ os.write((byte) green);
+ os.write((byte) blue);
+ }
+ else
+ {
+ os.write(("" + red).getBytes()); // max component value
+ os.write(' ');
+ os.write(("" + green).getBytes()); // max component value
+ os.write(' ');
+ os.write(("" + blue).getBytes()); // max component value
+ os.write(' ');
+ }
+ }
+ }
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/WhiteSpaceReader.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/WhiteSpaceReader.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/WhiteSpaceReader.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/WhiteSpaceReader.java Fri Sep 10 16:33:35 2010
@@ -21,52 +21,52 @@ import java.io.InputStream;
class WhiteSpaceReader
{
- private final InputStream is;
+ private final InputStream is;
- public WhiteSpaceReader(InputStream is)
- {
- this.is = is;
- }
-
- int count = 0;
-
- private char read() throws IOException
- {
- int result = is.read();
- if (result < 0)
- throw new IOException("PNM: Unexpected EOF");
- return (char) result;
- }
-
- public char nextChar() throws IOException
- {
- char c = read();
-
- if (c == '#')
- {
- while ((c != '\n') && (c != '\r'))
- {
- c = read();
- }
- }
- return c;
- }
-
- public String readtoWhiteSpace() throws IOException
- {
- char c = nextChar();
-
- while (Character.isWhitespace(c))
- c = nextChar();
-
- StringBuffer buffer = new StringBuffer();
-
- while (!Character.isWhitespace(c))
- {
- buffer.append(c);
- c = nextChar();
- }
+ public WhiteSpaceReader(InputStream is)
+ {
+ this.is = is;
+ }
+
+ int count = 0;
+
+ private char read() throws IOException
+ {
+ int result = is.read();
+ if (result < 0)
+ throw new IOException("PNM: Unexpected EOF");
+ return (char) result;
+ }
+
+ public char nextChar() throws IOException
+ {
+ char c = read();
+
+ if (c == '#')
+ {
+ while ((c != '\n') && (c != '\r'))
+ {
+ c = read();
+ }
+ }
+ return c;
+ }
+
+ public String readtoWhiteSpace() throws IOException
+ {
+ char c = nextChar();
+
+ while (Character.isWhitespace(c))
+ c = nextChar();
+
+ StringBuffer buffer = new StringBuffer();
+
+ while (!Character.isWhitespace(c))
+ {
+ buffer.append(c);
+ c = nextChar();
+ }
- return buffer.toString();
- }
+ return buffer.toString();
+ }
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageContents.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageContents.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageContents.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageContents.java Fri Sep 10 16:33:35 2010
@@ -20,52 +20,52 @@ import java.io.PrintWriter;
public class ImageContents
{
- public final PSDHeaderInfo header;
+ public final PSDHeaderInfo header;
- public final int ColorModeDataLength;
- public final int ImageResourcesLength;
- public final int LayerAndMaskDataLength;
- public final int Compression;
-
- public ImageContents(PSDHeaderInfo header,
-
- int ColorModeDataLength, int ImageResourcesLength,
- int LayerAndMaskDataLength, int Compression)
- {
- this.header = header;
- this.ColorModeDataLength = ColorModeDataLength;
- this.ImageResourcesLength = ImageResourcesLength;
- this.LayerAndMaskDataLength = LayerAndMaskDataLength;
- this.Compression = Compression;
- }
-
- public void dump()
- {
- PrintWriter pw = new PrintWriter(System.out);
- dump(pw);
- pw.flush();
- }
-
- public void dump(PrintWriter pw)
- {
- pw.println("");
- pw.println("ImageContents");
- pw.println("Compression: " + Compression + " ("
- + Integer.toHexString(Compression) + ")");
- pw.println("ColorModeDataLength: " + ColorModeDataLength + " ("
- + Integer.toHexString(ColorModeDataLength) + ")");
- pw.println("ImageResourcesLength: " + ImageResourcesLength + " ("
- + Integer.toHexString(ImageResourcesLength) + ")");
- pw.println("LayerAndMaskDataLength: " + LayerAndMaskDataLength + " ("
- + Integer.toHexString(LayerAndMaskDataLength) + ")");
- // System.out.println("Depth: " + Depth + " ("
- // + Integer.toHexString(Depth) + ")");
- // System.out.println("Mode: " + Mode + " (" + Integer.toHexString(Mode)
- // + ")");
- // System.out.println("Reserved: " + Reserved.length);
- pw.println("");
- pw.flush();
+ public final int ColorModeDataLength;
+ public final int ImageResourcesLength;
+ public final int LayerAndMaskDataLength;
+ public final int Compression;
+
+ public ImageContents(PSDHeaderInfo header,
+
+ int ColorModeDataLength, int ImageResourcesLength,
+ int LayerAndMaskDataLength, int Compression)
+ {
+ this.header = header;
+ this.ColorModeDataLength = ColorModeDataLength;
+ this.ImageResourcesLength = ImageResourcesLength;
+ this.LayerAndMaskDataLength = LayerAndMaskDataLength;
+ this.Compression = Compression;
+ }
+
+ public void dump()
+ {
+ PrintWriter pw = new PrintWriter(System.out);
+ dump(pw);
+ pw.flush();
+ }
+
+ public void dump(PrintWriter pw)
+ {
+ pw.println("");
+ pw.println("ImageContents");
+ pw.println("Compression: " + Compression + " ("
+ + Integer.toHexString(Compression) + ")");
+ pw.println("ColorModeDataLength: " + ColorModeDataLength + " ("
+ + Integer.toHexString(ColorModeDataLength) + ")");
+ pw.println("ImageResourcesLength: " + ImageResourcesLength + " ("
+ + Integer.toHexString(ImageResourcesLength) + ")");
+ pw.println("LayerAndMaskDataLength: " + LayerAndMaskDataLength + " ("
+ + Integer.toHexString(LayerAndMaskDataLength) + ")");
+ // System.out.println("Depth: " + Depth + " ("
+ // + Integer.toHexString(Depth) + ")");
+ // System.out.println("Mode: " + Mode + " (" + Integer.toHexString(Mode)
+ // + ")");
+ // System.out.println("Reserved: " + Reserved.length);
+ pw.println("");
+ pw.flush();
- }
+ }
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceBlock.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceBlock.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceBlock.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceBlock.java Fri Sep 10 16:33:35 2010
@@ -22,20 +22,20 @@ import org.apache.sanselan.util.Debug;
class ImageResourceBlock
{
- protected final int id;
- protected final byte nameData[];
- protected final byte data[];
+ protected final int id;
+ protected final byte nameData[];
+ protected final byte data[];
- public ImageResourceBlock(int ID, byte NameData[], byte Data[])
- {
- this.id = ID;
- this.nameData = NameData;
- this.data = Data;
- }
+ public ImageResourceBlock(int ID, byte NameData[], byte Data[])
+ {
+ this.id = ID;
+ this.nameData = NameData;
+ this.data = Data;
+ }
- public String getName() throws UnsupportedEncodingException
- {
- Debug.debug("getName", nameData.length);
- return new String(nameData, "ISO-8859-1");
- }
+ public String getName() throws UnsupportedEncodingException
+ {
+ Debug.debug("getName", nameData.length);
+ return new String(nameData, "ISO-8859-1");
+ }
}
\ No newline at end of file
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceType.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceType.java?rev=995859&r1=995858&r2=995859&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceType.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceType.java Fri Sep 10 16:33:35 2010
@@ -22,21 +22,21 @@ import org.apache.sanselan.ImageReadExce
public class ImageResourceType
{
- public final int ID;
- public final String Description;
+ public final int ID;
+ public final String Description;
- public ImageResourceType(int ID, String Description)
- {
- this.ID = ID;
- this.Description = Description;
- }
+ public ImageResourceType(int ID, String Description)
+ {
+ this.ID = ID;
+ this.Description = Description;
+ }
- public ImageResourceType(int ID, int ID2, String Description)
- throws ImageReadException, IOException
- {
- this(ID, Description);
- if (ID != ID2)
- throw new ImageReadException("Mismatch ID: " + ID + " ID2: " + ID2);
+ public ImageResourceType(int ID, int ID2, String Description)
+ throws ImageReadException, IOException
+ {
+ this(ID, Description);
+ if (ID != ID2)
+ throw new ImageReadException("Mismatch ID: " + ID + " ID2: " + ID2);
- }
+ }
}
\ No newline at end of file