You are viewing a plain text version of this content. The canonical link for it is here.
Posted to sanselan-commits@incubator.apache.org by cm...@apache.org on 2007/11/29 02:27:15 UTC

svn commit: r599250 [8/15] - in /incubator/sanselan/trunk/src/main/java/org: apache/sanselan/ apache/sanselan/color/ apache/sanselan/common/ apache/sanselan/common/byteSources/ apache/sanselan/common/mylzw/ apache/sanselan/formats/bmp/ apache/sanselan/...

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGChunkzTXt.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGChunkzTXt.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGChunkzTXt.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGChunkzTXt.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,84 @@
+/*
+ * 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.sanselan.formats.png.chunks;
+
+import java.io.IOException;
+
+import org.apache.sanselan.ImageReadException;
+import org.apache.sanselan.common.ZLibInflater;
+
+public class PNGChunkzTXt extends PNGTextChunk
+{
+
+	//	private final PngImageParser parser;
+	public final String Keyword, Text;
+
+	public PNGChunkzTXt(
+	//			PngImageParser parser, 
+			int Length, int ChunkType, int CRC, byte bytes[])
+			throws ImageReadException, IOException
+	{
+		super(Length, ChunkType, CRC, bytes);
+		//		this.parser = parser;
+
+		{
+			int index = findNull(bytes);
+			if (index < 0)
+				throw new ImageReadException("PNGChunkiCCP: No Profile Name");
+			byte Keyword_bytes[] = new byte[index];
+			System.arraycopy(bytes, 0, Keyword_bytes, 0, index);
+			Keyword = new String(Keyword_bytes);
+
+			int CompressionMethod = bytes[index + 1];
+
+			int CompressedTextLength = bytes.length - (index + 1 + 1);
+			byte CompressedText[] = new byte[CompressedTextLength];
+			System.arraycopy(bytes, index + 1 + 1, CompressedText, 0,
+					CompressedTextLength);
+
+			if (getDebug())
+			{
+				System.out.println("Keyword: " + Keyword);
+			}
+
+			Text = new String(new ZLibInflater().zlibInflate(CompressedText));
+
+			if (getDebug())
+			{
+				System.out.println("Text: " + Text);
+			}
+
+		}
+	}
+
+	/**
+	 * @return Returns the keyword.
+	 */
+	public String getKeyword()
+	{
+		return Keyword;
+	}
+
+	/**
+	 * @return Returns the text.
+	 */
+	public String getText()
+	{
+		return Text;
+	}
+
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGChunkzTXt.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGTextChunk.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGTextChunk.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGTextChunk.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGTextChunk.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,35 @@
+/*
+ * 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.sanselan.formats.png.chunks;
+
+import java.io.IOException;
+
+public abstract class PNGTextChunk extends PNGChunk
+{
+
+	public PNGTextChunk(int Length, int ChunkType, int CRC, byte bytes[])
+			throws IOException
+	{
+		super(Length, ChunkType, CRC, bytes);
+
+	}
+
+	public abstract String getKeyword();
+
+	public abstract String getText();
+
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/chunks/PNGTextChunk.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilter.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilter.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilter.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilter.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,27 @@
+/*
+ * 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.sanselan.formats.png.scanlinefilters;
+
+import java.io.IOException;
+
+import org.apache.sanselan.ImageReadException;
+
+public abstract class ScanlineFilter
+{
+	public abstract void unfilter(byte src[], byte dst[], byte up[])
+			throws ImageReadException, IOException;
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterAverage.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterAverage.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterAverage.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterAverage.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,53 @@
+/*
+ * 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.sanselan.formats.png.scanlinefilters;
+
+import java.io.IOException;
+
+import org.apache.sanselan.ImageReadException;
+
+public class ScanlineFilterAverage extends ScanlineFilter
+{
+	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;
+		}
+	}
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterAverage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterNone.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterNone.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterNone.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterNone.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,33 @@
+/*
+ * 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.sanselan.formats.png.scanlinefilters;
+
+import java.io.IOException;
+
+import org.apache.sanselan.ImageReadException;
+
+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];
+		}
+	}
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterNone.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterPaeth.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterPaeth.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterPaeth.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterPaeth.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,79 @@
+/*
+ * 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.sanselan.formats.png.scanlinefilters;
+
+import java.io.IOException;
+
+import org.apache.sanselan.ImageReadException;
+
+public class ScanlineFilterPaeth extends ScanlineFilter
+{
+	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;
+		}
+	}
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterPaeth.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterSub.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterSub.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterSub.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterSub.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,50 @@
+/*
+ * 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.sanselan.formats.png.scanlinefilters;
+
+import java.io.IOException;
+
+import org.apache.sanselan.ImageReadException;
+
+public class ScanlineFilterSub extends ScanlineFilter
+{
+	private final int 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];
+
+			//				if(i<10) 
+			//					System.out.println("\t" + i + ": " + dst[i] + " (" + src[i] + ", " + prev_index + ")");
+
+			//				dst[i] = src[i];
+		}
+	}
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterSub.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterUp.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterUp.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterUp.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterUp.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,51 @@
+/*
+ * 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.sanselan.formats.png.scanlinefilters;
+
+import java.io.IOException;
+
+import org.apache.sanselan.ImageReadException;
+
+public class ScanlineFilterUp extends ScanlineFilter
+{
+	private final int 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;
+
+			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;
+		}
+	}
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/scanlinefilters/ScanlineFilterUp.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/FileInfo.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/FileInfo.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/FileInfo.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/FileInfo.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,101 @@
+/*
+ * 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.sanselan.formats.pnm;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.sanselan.ImageFormat;
+
+public abstract class FileInfo
+{
+	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;
+
+	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++;
+				}
+		}
+		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++;
+				}
+			}
+		}
+		//			}
+		//			finally
+		//			{
+		//				System.out.println("count: " + count);
+		//				dump();
+		//			}
+	}
+
+	public void dump()
+	{
+
+	}
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/FileInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMFileInfo.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMFileInfo.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMFileInfo.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMFileInfo.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,97 @@
+/*
+ * 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.sanselan.formats.pnm;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.sanselan.ImageFormat;
+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";
+	}
+
+	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

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMFileInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMWriter.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMWriter.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMWriter.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMWriter.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,98 @@
+/*
+ * 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.sanselan.formats.pnm;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Map;
+
+import org.apache.sanselan.ImageWriteException;
+
+public class PBMWriter extends PNMWriter
+{
+	public PBMWriter(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 ? 0x34 : 0x31);
+		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');
+
+		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(' ');
+				}
+			}
+
+			if ((RAWBITS) && (bits_in_cache > 0))
+			{
+				os.write((byte) bitcache);
+				bitcache = 0;
+				bits_in_cache = 0;
+			}
+		}
+	}
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PBMWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMFileInfo.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMFileInfo.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMFileInfo.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMFileInfo.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,92 @@
+/*
+ * 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.sanselan.formats.pnm;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.sanselan.ImageFormat;
+import org.apache.sanselan.ImageInfo;
+
+public class PGMFileInfo extends FileInfo
+{
+	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());
+
+		int alpha = 0xff;
+
+		int rgb = ((0xff & alpha) << 24) | ((0xff & sample) << 16)
+				| ((0xff & sample) << 8) | ((0xff & sample) << 0);
+
+		return rgb;
+	}
+
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMFileInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMWriter.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMWriter.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMWriter.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMWriter.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,75 @@
+/*
+ * 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.sanselan.formats.pnm;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Map;
+
+import org.apache.sanselan.ImageWriteException;
+
+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(' ');
+				}
+			}
+	}
+
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PGMWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMImageParser.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMImageParser.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMImageParser.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMImageParser.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,360 @@
+/*
+ * 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.sanselan.formats.pnm;
+
+import java.awt.Dimension;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Vector;
+
+import org.apache.sanselan.ImageFormat;
+import org.apache.sanselan.ImageInfo;
+import org.apache.sanselan.ImageParser;
+import org.apache.sanselan.ImageReadException;
+import org.apache.sanselan.ImageWriteException;
+import org.apache.sanselan.common.IImageMetadata;
+import org.apache.sanselan.common.byteSources.ByteSource;
+import org.apache.sanselan.util.Debug;
+
+public class PNMImageParser extends ImageParser
+{
+
+	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 == 'P') && (Identifier2 == '1'))
+		{
+			return new PBMFileInfo(width, height, false);
+		}
+		if ((Identifier1 == 'P') && (Identifier2 == '2'))
+		{
+			int maxgray = Integer.parseInt(wsr.readtoWhiteSpace());
+			//			System.out.println("maxgray: " + maxgray);
+			return new PGMFileInfo(width, height, false, maxgray);
+		}
+		if ((Identifier1 == 'P') && (Identifier2 == '3'))
+		{
+			int max = Integer.parseInt(wsr.readtoWhiteSpace());
+			//			System.out.println("max: " + max);
+			return new PPMFileInfo(width, height, false, max);
+		}
+		if ((Identifier1 == 'P') && (Identifier2 == '4'))
+		{
+			return new PBMFileInfo(width, height, true);
+		}
+		if ((Identifier1 == 'P') && (Identifier2 == '5'))
+		{
+			int maxgray = Integer.parseInt(wsr.readtoWhiteSpace());
+			//			System.out.println("maxgray: " + maxgray);
+			return new PGMFileInfo(width, height, true, maxgray);
+		}
+		if ((Identifier1 == 'P') && (Identifier2 == '6'))
+		{
+			int max = Integer.parseInt(wsr.readtoWhiteSpace());
+			//			System.out.println("max: " + max);
+			return new PPMFileInfo(width, height, true, max);
+		}
+
+		throw new ImageReadException("PNM: Bad Magic Number: " + Identifier1
+				+ ", " + Identifier2);
+	}
+
+	private FileInfo readHeader(ByteSource byteSource)
+			throws ImageReadException, IOException
+	{
+		InputStream is = null;
+
+		try
+		{
+			is = byteSource.getInputStream();
+
+			return readHeader(is);
+		}
+		finally
+		{
+			try
+			{
+				is.close();
+			}
+			catch (Exception e)
+			{
+				Debug.debug(e);
+			}
+		}
+	}
+
+	public byte[] getICCProfileBytes(ByteSource byteSource)
+			throws ImageReadException, IOException
+	{
+		return null;
+	}
+
+	public Dimension getImageSize(ByteSource byteSource)
+			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)
+			throws ImageReadException, IOException
+	{
+		FileInfo info = readHeader(byteSource);
+
+		if (info == null)
+			throw new ImageReadException("PNM: Couldn't read Header");
+
+		Vector Comments = new Vector();
+
+		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 fImageData = getImageInfo(byteSource);
+			if (fImageData == null)
+				return false;
+
+			fImageData.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
+			{
+				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 RAWBITS = true;
+
+		if (params != null)
+		{
+			Object fRAWBITS = params.get(PARAM_KEY_PNM_RAWBITS);
+			if (fRAWBITS != null)
+			{
+				if (fRAWBITS.equals(PARAM_VALUE_PNM_RAWBITS_NO))
+					RAWBITS = false;
+			}
+
+			Object subtype = params.get(PARAM_KEY_FORMAT);
+			if (subtype != null)
+			{
+				if (subtype.equals(ImageFormat.IMAGE_FORMAT_PBM))
+					writer = new PBMWriter(RAWBITS);
+				else if (subtype.equals(ImageFormat.IMAGE_FORMAT_PGM))
+					writer = new PGMWriter(RAWBITS);
+				else if (subtype.equals(ImageFormat.IMAGE_FORMAT_PPM))
+					writer = new PPMWriter(RAWBITS);
+			}
+		}
+
+		if (writer == null)
+			writer = new PPMWriter(RAWBITS);
+
+		// make copy of params; we'll clear keys as we consume them.
+		params = new Hashtable(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);
+	}
+
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMImageParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMWriter.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMWriter.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMWriter.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMWriter.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,37 @@
+/*
+ * 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.sanselan.formats.pnm;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Map;
+
+import org.apache.sanselan.ImageWriteException;
+
+public abstract class PNMWriter
+{
+	protected final boolean RAWBITS;
+
+	public PNMWriter(boolean RAWBITS)
+	{
+		this.RAWBITS = RAWBITS;
+	}
+
+	public abstract void writeImage(BufferedImage src, OutputStream os,
+			Map params) throws ImageWriteException, IOException;
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMFileInfo.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMFileInfo.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMFileInfo.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMFileInfo.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,101 @@
+/*
+ * 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.sanselan.formats.pnm;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.sanselan.ImageFormat;
+import org.apache.sanselan.ImageInfo;
+
+public class PPMFileInfo extends FileInfo
+{
+	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);
+	}
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMFileInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMWriter.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMWriter.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMWriter.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMWriter.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,79 @@
+/*
+ * 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.sanselan.formats.pnm;
+
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Map;
+
+import org.apache.sanselan.ImageWriteException;
+
+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(' ');
+				}
+			}
+	}
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PPMWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/WhiteSpaceReader.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/WhiteSpaceReader.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/WhiteSpaceReader.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/WhiteSpaceReader.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,72 @@
+/*
+ * 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.sanselan.formats.pnm;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+class WhiteSpaceReader
+{
+	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 = (char) read();
+
+		if (c == '#')
+		{
+			while ((c != '\n') && (c != '\r'))
+			{
+				c = (char) 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();
+	}
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/WhiteSpaceReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageContents.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageContents.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageContents.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageContents.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,70 @@
+/*
+ * 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.sanselan.formats.psd;
+
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+
+public class ImageContents
+{
+	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()
+	{
+		dump(new PrintWriter(new OutputStreamWriter(System.out)));
+	}
+
+	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

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageContents.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceBlock.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceBlock.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceBlock.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceBlock.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,31 @@
+/*
+ * 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.sanselan.formats.psd;
+
+class ImageResourceBlock
+{
+	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;
+	}
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceBlock.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceType.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceType.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceType.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceType.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,42 @@
+/*
+ * 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.sanselan.formats.psd;
+
+import java.io.IOException;
+
+import org.apache.sanselan.ImageReadException;
+
+public class ImageResourceType
+{
+	public final int ID;
+	public final String 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);
+
+	}
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/ImageResourceType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/PSDConstants.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/PSDConstants.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/PSDConstants.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/PSDConstants.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,204 @@
+/*
+ * 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.sanselan.formats.psd;
+
+import org.apache.sanselan.util.Debug;
+
+public class PSDConstants
+{
+	public static final ImageResourceType fImageResourceTypes[];
+
+	public String getDescription(int id)
+	{
+		for (int i = 0; i < fImageResourceTypes.length; i++)
+		{
+			if (fImageResourceTypes[i].ID == id)
+				return fImageResourceTypes[i].Description;
+		}
+		return "Unknown";
+	}
+
+	static
+	{
+		ImageResourceType temp[] = null;
+
+		try
+		{
+			temp = new ImageResourceType[]{
+					new ImageResourceType(
+							0x03E8,
+							1000,
+							" Contains five 2 byte values: number of channels, rows, columns, depth, and mode."),
+					new ImageResourceType(0x03E9, 1001,
+							"Optional. Macintosh print manager print info record."),
+					new ImageResourceType(0x03EB, 1003,
+							" Contains the indexed color table."),
+					new ImageResourceType(0x03ED, 1005,
+							"ResolutionInfo structure. See Appendix A in Photoshop SDK Guide.pdf."),
+					new ImageResourceType(0x03EE, 1006,
+							"Names of the alpha channels as a series of Pascal strings."),
+					new ImageResourceType(0x03EF, 1007,
+							"DisplayInfo structure. See Appendix A in Photoshop SDK Guide.pdf ."),
+					new ImageResourceType(0x03F0, 1008,
+							"Optional. The caption as a Pascal string."),
+					new ImageResourceType(
+							0x03F1,
+							1009,
+							"Border information. Contains a fixed-number for the border width, and 2 bytes for border units (1=inches, 2=cm, 3=points, 4=picas, 5=columns)."),
+					new ImageResourceType(0x03F2, 1010,
+							"Background color. See the Colors additional file information."),
+					new ImageResourceType(
+							0x03F3,
+							1011,
+							"Print flags. A series of one byte boolean values (see Page Setup dialog): labels, crop marks, color bars, registration marks, negative, flip, interpolate, caption."),
+					new ImageResourceType(0x03F4, 1012,
+							"Grayscale and multichannel halftoning information."),
+					new ImageResourceType(0x03F5, 1013,
+							"Color halftoning information."),
+					new ImageResourceType(0x03F6, 1014,
+							"Duotone halftoning information."),
+					new ImageResourceType(0x03F7, 1015,
+							"Grayscale and multichannel transfer function."),
+					new ImageResourceType(0x03F8, 1016,
+							"Color transfer functions."),
+					new ImageResourceType(0x03F9, 1017,
+							"Duotone transfer functions."),
+					new ImageResourceType(0x03FA, 1018,
+							"Duotone image information."),
+					new ImageResourceType(0x03FB, 1019,
+							"Two bytes for the effective black and white values for the dot range."),
+					new ImageResourceType(0x03FC, 1020, "Obsolete."),
+					new ImageResourceType(0x03FD, 1021, "EPS options."),
+					new ImageResourceType(
+							0x03FE,
+							1022,
+							"Quick Mask information. 2 bytes containing Quick Mask channel ID, 1 byte boolean indicating whether the mask was initially empty."),
+					new ImageResourceType(0x03FF, 1023, "Obsolete."),
+					new ImageResourceType(
+							0x0400,
+							1024,
+							"Layer state information. 2 bytes containing the index of target layer. 0=bottom layer."),
+					new ImageResourceType(0x0401, 1025,
+							"Working path (not saved). See path resource format later in this chapter."),
+					new ImageResourceType(
+							0x0402,
+							1026,
+							"Layers group information. 2 bytes per layer containing a group ID for the dragging groups. Layers in a group have the same group ID."),
+					new ImageResourceType(0x0403, 1027, "Obsolete."),
+					new ImageResourceType(
+							0x0404,
+							1028,
+							"IPTC-NAA record. This contains the File Info... information. See the IIMV4.pdf document."),
+					new ImageResourceType(0x0405, 1029,
+							"Image mode for raw format files."),
+					new ImageResourceType(0x0406, 1030,
+							"JPEG quality. Private."),
+					new ImageResourceType(
+							0x0408,
+							1032,
+							"Grid and guides information. See grid and guides resource format later in this chapter."),
+					new ImageResourceType(0x0409, 1033,
+							"Thumbnail resource. See thumbnail resource format later in this chapter."),
+					new ImageResourceType(
+							0x040A,
+							1034,
+							"Copyright flag. Boolean indicating whether image is copyrighted. Can be set via Property suite or by user in File Info..."),
+					new ImageResourceType(
+							0x040B,
+							1035,
+							"URL. Handle of a text string with uniform resource locator. Can be set via Property suite or by user in File Info..."),
+					new ImageResourceType(0x040C, 1036,
+							"Thumbnail resource. See thumbnail resource format later in this chapter."),
+					new ImageResourceType(
+							0x040D,
+							1037,
+							"Global Angle. 4 bytes that contain an integer between 0..359 which is the global lighting angle for effects layer. If not present assumes 30."),
+					new ImageResourceType(
+							0x040E,
+							1038,
+							"Color samplers resource. See color samplers resource format later in this chapter."),
+					new ImageResourceType(
+							0x040F,
+							1039,
+							"ICC Profile. The raw bytes of an ICC format profile, see the ICC34.pdf and ICC34.h files from the Internation Color Consortium located in the documentation section."),
+					new ImageResourceType(0x0410, 1040,
+							"One byte for Watermark."),
+					new ImageResourceType(
+							0x0411,
+							1041,
+							"ICC Untagged. 1 byte that disables any assumed profile handling when opening the file. 1 = intentionally untagged."),
+					new ImageResourceType(
+							0x0412,
+							1042,
+							"Effects visible. 1 byte global flag to show/hide all the effects layer. Only present when they are hidden."),
+					new ImageResourceType(
+							0x0413,
+							1043,
+							"Spot Halftone. 4 bytes for version, 4 bytes for length, and the variable length data."),
+					new ImageResourceType(
+							0x0414,
+							1044,
+							"Document specific IDs, layer IDs will be generated starting at this base value or a greater value if we find existing IDs to already exceed it. It’s purpose is to avoid the case where we add layers, flatten, save, open, and then add more layers that end up with the same IDs as the first set. 4 bytes."),
+					new ImageResourceType(0x0415, 1045,
+							"Unicode Alpha Names. 4 bytes for length and the string as a unicode string."),
+					new ImageResourceType(
+							0x0416,
+							1046,
+							"Indexed Color Table Count. 2 bytes for the number of colors in table that are actually defined"),
+					new ImageResourceType(0x0417, 1047,
+							"Tansparent Index. 2 bytes for the index of transparent color, if any."),
+					new ImageResourceType(0x0419, 1049,
+							"Global Altitude. 4 byte entry for altitude"),
+					new ImageResourceType(0x041A, 1050,
+							"Slices. See description later in this chapter"),
+					new ImageResourceType(0x041B, 1051,
+							"Workflow URL. Unicode string, 4 bytes of length followed by unicode string."),
+					new ImageResourceType(
+							0x041C,
+							1052,
+							"Jump To XPEP. 2 bytes major version, 2 bytes minor version, 4 bytes count. Following is repeated for count: 4 bytes block size, 4 bytes key, if key = 'jtDd' then next is a Boolean for the dirty flag otherwise it’s a 4 byte entry for the mod date."),
+					new ImageResourceType(
+							0x041D,
+							1053,
+							"Alpha Identifiers. 4 bytes of length, followed by 4 bytes each for every alpha identifier."),
+					new ImageResourceType(
+							0x041E,
+							1054,
+							"URL List. 4 byte count of URLs, followed by 4 byte long, 4 byte ID, and unicode string for each count."),
+					new ImageResourceType(
+							0x0421,
+							1057,
+							"Version Info. 4 byte version, 1 byte HasRealMergedData, unicode string of writer name, unicode string of reader name, 4 bytes of file version."),
+					new ImageResourceType(
+							0x07D0 - 0x0BB6,
+							2000 - 2998,
+							"Path Information (saved paths). See path resource format later in this chapter."),
+					new ImageResourceType(0x0BB7, 2999,
+							"Name of clipping path. See path resource format later in this chapter."),
+					new ImageResourceType(
+							0x2710,
+							10000,
+							"Print flags information. 2 bytes version (=1), 1 byte center crop marks, 1 byte (=0), 4 bytes bleed width value, 2 bytes bleed width scale."),
+			};
+		}
+		catch (Exception e)
+		{
+			Debug.debug(PSDConstants.class, e);
+		}
+		fImageResourceTypes = temp;
+	};
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/PSDConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/PSDHeaderInfo.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/PSDHeaderInfo.java?rev=599250&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/PSDHeaderInfo.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/PSDHeaderInfo.java Wed Nov 28 18:27:05 2007
@@ -0,0 +1,69 @@
+/*
+ * 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.sanselan.formats.psd;
+
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+
+public class PSDHeaderInfo
+{
+	public final int Version;
+	public final byte Reserved[];
+	public final int Channels;
+	public final int Rows;
+	public final int Columns;
+	public final int Depth;
+	public final int Mode;
+
+	public PSDHeaderInfo(int Version, byte Reserved[], int Channels, int Rows,
+			int Columns, int Depth, int Mode)
+	{
+		this.Version = Version;
+		this.Reserved = Reserved;
+		this.Channels = Channels;
+		this.Rows = Rows;
+		this.Columns = Columns;
+		this.Depth = Depth;
+		this.Mode = Mode;
+
+	}
+
+	public void dump()
+	{
+		dump(new PrintWriter(new OutputStreamWriter(System.out)));
+	}
+
+	public void dump(PrintWriter pw)
+	{
+		pw.println("");
+		pw.println("Header");
+		pw.println("Version: " + Version + " (" + Integer.toHexString(Version)
+				+ ")");
+		pw.println("Channels: " + Channels + " ("
+				+ Integer.toHexString(Channels) + ")");
+		pw.println("Rows: " + Rows + " (" + Integer.toHexString(Rows) + ")");
+		pw.println("Columns: " + Columns + " (" + Integer.toHexString(Columns)
+				+ ")");
+		pw.println("Depth: " + Depth + " (" + Integer.toHexString(Depth) + ")");
+		pw.println("Mode: " + Mode + " (" + Integer.toHexString(Mode) + ")");
+		pw.println("Reserved: " + Reserved.length);
+		pw.println("");
+		pw.flush();
+
+	}
+
+}
\ No newline at end of file

Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/PSDHeaderInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native