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/12/29 06:48:53 UTC
svn commit: r607388 [2/8] - in /incubator/sanselan/trunk/src:
main/java/org/apache/sanselan/ main/java/org/apache/sanselan/common/
main/java/org/apache/sanselan/common/mylzw/
main/java/org/apache/sanselan/formats/bmp/
main/java/org/apache/sanselan/form...
Modified: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TagInfo.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TagInfo.java?rev=607388&r1=607387&r2=607388&view=diff
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TagInfo.java (original)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TagInfo.java Fri Dec 28 22:48:44 2007
@@ -1,85 +1,86 @@
-/*
- * 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.tiff;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.apache.sanselan.util.Debug;
-
-public class TagInfo
-{
- public final int tag;
- public final String name;
- public final boolean isDate;
-
- public TagInfo(int tag, String name)
- {
- this(tag, name, false);
- }
-
- public TagInfo(int tag, String name, boolean is_date)
- {
- this.tag = tag;
- this.name = name.trim();
- this.isDate = is_date;
- }
-
- private static final DateFormat DATE_FORMAT_1 = new SimpleDateFormat(
- "yyyy:MM:dd HH:mm:ss");
- private static final DateFormat DATE_FORMAT_2 = new SimpleDateFormat(
- "yyyy:MM:dd:HH:mm:ss");
-
- public Object getValue(TiffField entry)
- {
- Object o = entry.fieldType.getSimpleValue(entry);
-
- if (isDate)
- {
- String s = (String) o;
- try
- {
- Date date = DATE_FORMAT_1.parse(s);
- return date;
- }
- catch (Exception e)
- {
- // Debug.debug(e);
- }
- try
- {
- Date date = DATE_FORMAT_2.parse(s);
- return date;
- }
- catch (Exception e)
- {
- Debug.debug(e);
- }
-
- }
-
- return o;
- }
-
- public String toString()
- {
- return "[TagInfo. tag: " + tag + ", name: " + name
- + (isDate ? " (data)" : "") + "]";
- }
-
-}
\ No newline at end of file
+///*
+// * 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.tiff;
+//
+//import java.text.DateFormat;
+//import java.text.SimpleDateFormat;
+//import java.util.Date;
+//
+//import org.apache.sanselan.util.Debug;
+//
+//public class TagInfo
+//{
+// public final int tag;
+// public final String name;
+// public final boolean isDate;
+//
+// public TagInfo(int tag, String name)
+// {
+// this(tag, name, false);
+// }
+//
+// public TagInfo(int tag, String name, boolean is_date)
+// {
+// this.tag = tag;
+// this.name = name.trim();
+// this.isDate = is_date;
+// }
+//
+// private static final DateFormat DATE_FORMAT_1 = new SimpleDateFormat(
+// "yyyy:MM:dd HH:mm:ss");
+// private static final DateFormat DATE_FORMAT_2 = new SimpleDateFormat(
+// "yyyy:MM:dd:HH:mm:ss");
+//
+// public Object getValue(TiffField entry)
+// {
+// Object o = entry.fieldType.getSimpleValue(entry);
+//
+// if (isDate)
+// {
+// String s = (String) o;
+// try
+// {
+// Date date = DATE_FORMAT_1.parse(s);
+// return date;
+// }
+// catch (Exception e)
+// {
+// // Debug.debug(e);
+// }
+// try
+// {
+// Date date = DATE_FORMAT_2.parse(s);
+// return date;
+// }
+// catch (Exception e)
+// {
+// Debug.debug(e);
+// }
+//
+// }
+//
+// return o;
+// }
+//
+// public String toString()
+// {
+// return "[TagInfo. tag: " + tag + ", name: " + name
+// + (isDate ? " (data)" : "") + "]";
+// }
+//
+//}
+//
Modified: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffContents.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffContents.java?rev=607388&r1=607387&r2=607388&view=diff
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffContents.java (original)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffContents.java Fri Dec 28 22:48:44 2007
@@ -16,26 +16,27 @@
*/
package org.apache.sanselan.formats.tiff;
+import java.util.ArrayList;
import java.util.Collections;
-import java.util.Vector;
import org.apache.sanselan.ImageReadException;
+import org.apache.sanselan.formats.tiff.constants.TagInfo2;
import org.apache.sanselan.util.Debug;
public class TiffContents
{
public final TiffHeader header;
- public final Vector directories;
+ public final ArrayList directories;
- public TiffContents(TiffHeader tiffHeader, Vector directories)
+ public TiffContents(TiffHeader tiffHeader, ArrayList directories)
{
this.header = tiffHeader;
this.directories = directories;
}
- public Vector getElements() throws ImageReadException
+ public ArrayList getElements() throws ImageReadException
{
- Vector result = new Vector();
+ ArrayList result = new ArrayList();
result.add(header);
@@ -45,7 +46,7 @@
result.add(directory);
- Vector fields = directory.entries;
+ ArrayList fields = directory.entries;
for (int j = 0; j < fields.size(); j++)
{
TiffField field = (TiffField) fields.get(j);
@@ -63,7 +64,7 @@
return result;
}
- public TiffField findField(TagInfo tag)
+ public TiffField findField(TagInfo2 tag)
{
for (int i = 0; i < directories.size(); i++)
{
@@ -79,7 +80,7 @@
public void dissect(boolean verbose) throws ImageReadException
{
- Vector elements = getElements();
+ ArrayList elements = getElements();
Collections.sort(elements, TiffElement.COMPARATOR);
Modified: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffDirectory.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffDirectory.java?rev=607388&r1=607387&r2=607388&view=diff
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffDirectory.java (original)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffDirectory.java Fri Dec 28 22:48:44 2007
@@ -17,23 +17,16 @@
package org.apache.sanselan.formats.tiff;
import java.io.IOException;
-import java.util.Vector;
+import java.util.ArrayList;
import org.apache.sanselan.ImageReadException;
import org.apache.sanselan.common.byteSources.ByteSource;
+import org.apache.sanselan.formats.tiff.constants.TagInfo2;
+import org.apache.sanselan.formats.tiff.constants.TiffConstants;
public class TiffDirectory extends TiffElement implements TiffConstants
//extends BinaryFileFunctions
{
- public static final int DIRECTORY_TYPE_UNKNOWN = -1;
- public static final int DIRECTORY_TYPE_ROOT = 1;
- public static final int DIRECTORY_TYPE_SUB = 2;
- public static final int DIRECTORY_TYPE_THUMBNAIL = 3;
- public static final int DIRECTORY_TYPE_EXIF = 4;
- // public static final int DIRECTORY_TYPE_SUB = 5;
- public static final int DIRECTORY_TYPE_GPS = 6;
- public static final int DIRECTORY_TYPE_INTEROPERABILITY = 7;
-
public String description()
{
return TiffDirectory.description(type);
@@ -63,7 +56,7 @@
result.append("\n");
entryOffset += TIFF_ENTRY_LENGTH;
- // entry.fillInValue(byteSource);
+ // entry.fillInValue(byteSource);
}
return result.toString();
}
@@ -92,11 +85,11 @@
}
public final int type;
- public final Vector entries;
- // public final int offset;
+ public final ArrayList entries;
+ // public final int offset;
public final int nextDirectoryOffset;
- public TiffDirectory(int type, Vector entries, final int offset,
+ public TiffDirectory(int type, ArrayList entries, final int offset,
int nextDirectoryOffset)
{
super(offset, TIFF_DIRECTORY_HEADER_LENGTH + entries.size()
@@ -107,9 +100,9 @@
this.nextDirectoryOffset = nextDirectoryOffset;
}
- public Vector getDirectoryEntrys()
+ public ArrayList getDirectoryEntrys()
{
- return new Vector(entries);
+ return new ArrayList(entries);
}
public void fillInValues(ByteSource byteSource) throws ImageReadException,
@@ -135,7 +128,7 @@
public boolean hasJpegImageData()
{
- if (null != findField(TIFF_TAG_JPEGInterchangeFormat))
+ if (null != findField(TIFF_TAG_JPEG_INTERCHANGE_FORMAT))
return true;
return false;
@@ -143,16 +136,16 @@
public boolean hasTiffImageData()
{
- if (null != findField(TIFF_TAG_TileOffsets))
+ if (null != findField(TIFF_TAG_TILE_OFFSETS))
return true;
- if (null != findField(TIFF_TAG_StripOffsets))
+ if (null != findField(TIFF_TAG_STRIP_OFFSETS))
return true;
return false;
}
- public TiffField findField(TagInfo tag)
+ public TiffField findField(TagInfo2 tag)
{
if (entries == null)
return null;
@@ -182,7 +175,7 @@
}
}
- private Vector getRawImageDataElements(TiffField offsetsField,
+ private ArrayList getRawImageDataElements(TiffField offsetsField,
TiffField byteCountsField) throws ImageReadException
{
int offsets[] = offsetsField.getValueAsIntArray();
@@ -192,7 +185,7 @@
throw new ImageReadException("offsets.length(" + offsets.length
+ ") != byteCounts.length(" + byteCounts.length + ")");
- Vector result = new Vector();
+ ArrayList result = new ArrayList();
for (int i = 0; i < offsets.length; i++)
{
result.add(new ImageDataElement(offsets[i], byteCounts[i]));
@@ -200,12 +193,12 @@
return result;
}
- public Vector getTiffRawImageDataElements() throws ImageReadException
+ public ArrayList getTiffRawImageDataElements() throws ImageReadException
{
- TiffField tileOffsets = findField(TIFF_TAG_TileOffsets);
- TiffField tileByteCounts = findField(TIFF_TAG_TileByteCounts);
- TiffField stripOffsets = findField(TIFF_TAG_StripOffsets);
- TiffField stripByteCounts = findField(TIFF_TAG_StripByteCounts);
+ TiffField tileOffsets = findField(TIFF_TAG_TILE_OFFSETS);
+ TiffField tileByteCounts = findField(TIFF_TAG_TILE_BYTE_COUNTS);
+ TiffField stripOffsets = findField(TIFF_TAG_STRIP_OFFSETS);
+ TiffField stripByteCounts = findField(TIFF_TAG_STRIP_BYTE_COUNTS);
if ((tileOffsets != null) && (tileByteCounts != null))
{
@@ -221,10 +214,10 @@
public boolean imageDataInStrips() throws ImageReadException
{
- TiffField tileOffsets = findField(TIFF_TAG_TileOffsets);
- TiffField tileByteCounts = findField(TIFF_TAG_TileByteCounts);
- TiffField stripOffsets = findField(TIFF_TAG_StripOffsets);
- TiffField stripByteCounts = findField(TIFF_TAG_StripByteCounts);
+ TiffField tileOffsets = findField(TIFF_TAG_TILE_OFFSETS);
+ TiffField tileByteCounts = findField(TIFF_TAG_TILE_BYTE_COUNTS);
+ TiffField stripOffsets = findField(TIFF_TAG_STRIP_OFFSETS);
+ TiffField stripByteCounts = findField(TIFF_TAG_STRIP_BYTE_COUNTS);
if ((tileOffsets != null) && (tileByteCounts != null))
return false;
@@ -239,8 +232,8 @@
public ImageDataElement getJpegRawImageDataElement()
throws ImageReadException
{
- TiffField jpegInterchangeFormat = findField(TIFF_TAG_JPEGInterchangeFormat);
- TiffField jpegInterchangeFormatLength = findField(TIFF_TAG_JPEGInterchangeFormatLength);
+ TiffField jpegInterchangeFormat = findField(TIFF_TAG_JPEG_INTERCHANGE_FORMAT);
+ TiffField jpegInterchangeFormatLength = findField(TIFF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH);
if ((jpegInterchangeFormat != null)
&& (jpegInterchangeFormatLength != null))
Modified: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffField.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffField.java?rev=607388&r1=607387&r2=607388&view=diff
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffField.java (original)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffField.java Fri Dec 28 22:48:44 2007
@@ -27,17 +27,17 @@
import org.apache.sanselan.ImageReadException;
import org.apache.sanselan.common.byteSources.ByteSource;
+import org.apache.sanselan.formats.tiff.constants.TagInfo2;
+import org.apache.sanselan.formats.tiff.constants.TiffConstants;
import org.apache.sanselan.formats.tiff.fieldtypes.FieldType;
-public class TiffField
-//extends TiffElement
- implements
- TiffConstants
+public class TiffField implements TiffConstants
{
- public final TagInfo tagInfo;
+ public final TagInfo2 tagInfo;
public final FieldType fieldType;
public final int tag;
+ public final int directoryType;
public final int type;
public final int length;
public final int valueOffset;
@@ -46,14 +46,12 @@
public byte oversizeValue[] = null;
public final int byteOrder;
- public TiffField(
- // int offset,
- int tag, int type, int Length, int ValueOffset,
- byte ValueOffsetBytes[], int byteOrder)
+ public TiffField(int tag, int directoryType, int type, int Length,
+ int ValueOffset, byte ValueOffsetBytes[], int byteOrder)
{
- // super(offset, TiffConstants.TIFF_ENTRY_LENGTH);
this.tag = tag;
+ this.directoryType = directoryType;
this.type = type;
this.length = Length;
this.valueOffset = ValueOffset;
@@ -61,7 +59,7 @@
this.byteOrder = byteOrder;
fieldType = getFieldType(type);
- tagInfo = getTag(tag);
+ tagInfo = getTag(directoryType, tag);
}
public final class OversizeValueElement extends TiffElement
@@ -106,16 +104,48 @@
return FIELD_TYPE_UNKNOWN;
}
- private static TagInfo getTag(int value)
+ private static TagInfo2 getTag(int directoryType, int value)
{
- for (int i = 0; i < TIFF_TAGS.length; i++)
+ Object key = new Integer(value);
+
+ if (directoryType == DIRECTORY_TYPE_EXIF
+ || directoryType == DIRECTORY_TYPE_INTEROPERABILITY)
+ {
+ if (EXIF_TAG_MAP.containsKey(key))
+ return (TagInfo2) EXIF_TAG_MAP.get(key);
+ }
+ else if (directoryType == DIRECTORY_TYPE_GPS)
+ {
+ if (GPS_TAG_MAP.containsKey(key))
+ return (TagInfo2) GPS_TAG_MAP.get(key);
+ }
+ else
{
- TagInfo fTag = TIFF_TAGS[i];
- if (fTag.tag == value)
- return fTag;
+ if (TIFF_TAG_MAP.containsKey(key))
+ return (TagInfo2) TIFF_TAG_MAP.get(key);
}
- return TIFF_TAG_Unknown;
+ if (ALL_TAG_MAP.containsKey(key))
+ return (TagInfo2) ALL_TAG_MAP.get(key);
+
+ // public static final int DIRECTORY_TYPE_EXIF = -2;
+ // // public static final int DIRECTORY_TYPE_SUB = 5;
+ // public static final int DIRECTORY_TYPE_GPS = -3;
+ // public static final int DIRECTORY_TYPE_INTEROPERABILITY = -4;
+ //
+ // private static final Map GPS_TAG_MAP = makeTagMap(ALL_GPS_TAGS, false);
+ // private static final Map TIFF_TAG_MAP = makeTagMap(ALL_TIFF_TAGS, false);
+ // private static final Map EXIF_TAG_MAP = makeTagMap(ALL_EXIF_TAGS, false);
+ // private static final Map ALL_TAG_MAP = makeTagMap(ALL_TAGS, true);
+ //
+ // for (int i = 0; i < ALL_TAGS.length; i++)
+ // {
+ // TagInfo2 tag = ALL_TAGS[i];
+ // if (tag.tag == value)
+ // return tag;
+ // }
+
+ return TIFF_TAG_UNKNOWN;
}
private int getValueLengthInBytes()
@@ -393,6 +423,8 @@
public String getTagName()
{
+ if (tagInfo == TIFF_TAG_UNKNOWN)
+ return tagInfo.name + " (0x" + Integer.toHexString(tag) + ")";
return tagInfo.name;
}
@@ -409,26 +441,66 @@
return tagInfo.getValue(this);
}
- static
+ private static final Map makeTagMap(TagInfo2 tags[],
+ boolean ignoreDuplicates, String name)
{
+ // make sure to use the thread-safe version; this is shared state.
Map map = new Hashtable();
- for (int i = 0; i < TIFF_TAGS.length; i++)
+ for (int i = 0; i < tags.length; i++)
{
- TagInfo tag = TIFF_TAGS[i];
- Object o = map.get("" + tag.tag);
- if (o == null)
- map.put("" + tag.tag, tag);
- else
+ TagInfo2 tag = tags[i];
+ Object key = new Integer(tag.tag);
+
+ if (map.get(key) == null)
+ map.put(key, tag);
+ else if (!ignoreDuplicates)
{
- System.out.println("Duplicate tag: " + tag.tag);
+ System.out.println("Duplicate tag in " + name + ": " + tag.tag
+ + " (0x" + Integer.toHexString(tag.tag) + ")");
System.out.println("\t" + "New name: " + tag.name);
- System.out.println("\t" + "Old name: " + ((TagInfo) o).name);
+ System.out.println("\t" + "Old name: "
+ + ((TagInfo2) map.get(key)).name);
}
}
+ return map;
}
+ private static final Map GPS_TAG_MAP = makeTagMap(ALL_GPS_TAGS, false,
+ "GPS");
+ private static final Map TIFF_TAG_MAP = makeTagMap(ALL_TIFF_TAGS, false,
+ "TIFF");
+ private static final Map EXIF_TAG_MAP = makeTagMap(ALL_EXIF_TAGS, true,
+ "EXIF");
+ private static final Map ALL_TAG_MAP = makeTagMap(ALL_TAGS, true, "All");
+
+ // static
+ // {
+ // Map map = new HashMap();
+ //
+ // for (int i = 0; i < ALL_TAGS.length; i++)
+ // {
+ // TagInfo2 tag = ALL_TAGS[i];
+ // Object o = map.get("" + tag.tag);
+ // if (o == null)
+ // map.put("" + tag.tag, tag);
+ // else
+ // {
+ // System.out.println("Duplicate tag: " + tag.tag);
+ // System.out.println("\t" + "New name: " + tag.name);
+ // System.out.println("\t" + "Old name: " + ((TagInfo2) o).name);
+ // }
+ // }
+ //
+ // }
+
+ // public static final TagInfo2 ALL_TAGS[] = TagConstantsUtils
+ // .mergeTagLists(new TagInfo2[][]{
+ // ALL_EXIF_TAGS, ALL_TIFF_TAGS, ALL_GPS_TAGS,
+ // });
+ //
+ //
public int[] getValueAsIntArray()
{
Object o = getValue();
Modified: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffHeader.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffHeader.java?rev=607388&r1=607387&r2=607388&view=diff
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffHeader.java (original)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffHeader.java Fri Dec 28 22:48:44 2007
@@ -16,6 +16,8 @@
*/
package org.apache.sanselan.formats.tiff;
+import org.apache.sanselan.formats.tiff.constants.TiffConstants;
+
public class TiffHeader extends TiffElement
{
public final int byteOrder;
Modified: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffImageMetadata.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffImageMetadata.java?rev=607388&r1=607387&r2=607388&view=diff
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffImageMetadata.java (original)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffImageMetadata.java Fri Dec 28 22:48:44 2007
@@ -17,9 +17,15 @@
package org.apache.sanselan.formats.tiff;
import java.awt.image.BufferedImage;
-import java.util.Vector;
+import java.util.ArrayList;
+import org.apache.sanselan.ImageWriteException;
import org.apache.sanselan.common.ImageMetadata;
+import org.apache.sanselan.formats.tiff.constants.TagInfo2;
+import org.apache.sanselan.formats.tiff.fieldtypes.FieldType;
+import org.apache.sanselan.formats.tiff.write.TiffOutputDirectory;
+import org.apache.sanselan.formats.tiff.write.TiffOutputField;
+import org.apache.sanselan.formats.tiff.write.TiffOutputSet;
public class TiffImageMetadata extends ImageMetadata
{
@@ -89,21 +95,61 @@
{
return (prefix != null ? prefix : "") + directory.description()
+ ": " //
- + (rawTiffImageData != null ? " (rawImageData)" : "") //
+ + (rawTiffImageData != null ? " (tiffImageData)" : "") //
+ + (rawJpegImageData != null ? " (jpegImageData)" : "") //
+ "\n" + super.toString(prefix) + "\n";
}
+
+ public TiffOutputDirectory getOutputDirectory(int byteOrder)
+ throws ImageWriteException
+ {
+ TiffOutputDirectory dstDir = new TiffOutputDirectory(type);
+
+ ArrayList entries = getItems();
+ for (int i = 0; i < entries.size(); i++)
+ {
+ TiffImageMetadata.Item item = (TiffImageMetadata.Item) entries
+ .get(i);
+ TiffField srcField = item.getTiffField();
+
+ TagInfo2 tag = srcField.tagInfo;
+ FieldType tagtype = srcField.fieldType;
+ int count = srcField.length;
+ // byte bytes[] = srcField.fieldType.getRawBytes(srcField);
+
+ // Debug.debug("\t" + "srcField", srcField);
+ // Debug.debug("\t" + "bytes", bytes);
+
+ Object value = srcField.getValue();
+ byte bytes2[];
+ if (tag.isDate())
+ bytes2 = tagtype.getRawBytes(srcField);
+ else
+ bytes2 = tagtype.writeData(value, byteOrder);
+ // Debug.debug("\t" + "bytes2", bytes2);
+
+ TiffOutputField dstField = new TiffOutputField(tag, tagtype,
+ count, bytes2);
+ dstDir.add(dstField);
+ }
+
+ dstDir.setRawTiffImageData(getRawTiffImageData());
+ dstDir.setRawJpegImageData(getRawJpegImageData());
+
+ return dstDir;
+ }
}
- public Vector getDirectories()
+ public ArrayList getDirectories()
{
return super.getItems();
}
- public Vector getItems()
+ public ArrayList getItems()
{
- Vector result = new Vector();
+ ArrayList result = new ArrayList();
- Vector items = super.getItems();
+ ArrayList items = super.getItems();
for (int i = 0; i < items.size(); i++)
{
Directory dir = (Directory) items.get(i);
@@ -129,6 +175,24 @@
return entry;
}
+ }
+
+ public TiffOutputSet getOutputSet() throws ImageWriteException
+ {
+ int byteOrder = contents.header.byteOrder;
+ TiffOutputSet result = new TiffOutputSet(byteOrder);
+
+ ArrayList srcDirs = getDirectories();
+ for (int i = 0; i < srcDirs.size(); i++)
+ {
+ TiffImageMetadata.Directory srcDir = (TiffImageMetadata.Directory) srcDirs
+ .get(i);
+ TiffOutputDirectory outputDirectory = srcDir
+ .getOutputDirectory(byteOrder);
+ result.addDirectory(outputDirectory);
+ }
+
+ return result;
}
}
Modified: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffImageParser.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffImageParser.java?rev=607388&r1=607387&r2=607388&view=diff
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffImageParser.java (original)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/TiffImageParser.java Fri Dec 28 22:48:44 2007
@@ -23,8 +23,8 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
+import java.util.ArrayList;
import java.util.Map;
-import java.util.Vector;
import org.apache.sanselan.FormatCompliance;
import org.apache.sanselan.ImageFormat;
@@ -37,6 +37,8 @@
import org.apache.sanselan.common.byteSources.ByteSourceArray;
import org.apache.sanselan.common.byteSources.ByteSourceFile;
import org.apache.sanselan.formats.tiff.TiffDirectory.ImageDataElement;
+import org.apache.sanselan.formats.tiff.constants.TagInfo2;
+import org.apache.sanselan.formats.tiff.constants.TiffConstants;
import org.apache.sanselan.formats.tiff.datareaders.DataReader;
import org.apache.sanselan.formats.tiff.datareaders.DataReaderStrips;
import org.apache.sanselan.formats.tiff.datareaders.DataReaderTiled;
@@ -55,7 +57,7 @@
{
public TiffImageParser()
{
- // setDebug(true);
+ // setDebug(true);
}
public String getName()
@@ -131,13 +133,13 @@
int offset, int tags[], int maxEntriesToMatch)
throws ImageReadException, IOException
{
- Vector result = new Vector();
+ ArrayList result = new ArrayList();
int entryCount = read2Bytes("DirectoryEntryCount", is,
"Not a Valid TIFF File");
- // Debug.debug();
- // Debug.debug("readDirectory entryCount", entryCount);
+ // Debug.debug();
+ // Debug.debug("readDirectory entryCount", entryCount);
for (int i = 0; i < entryCount; i++)
{
@@ -152,12 +154,12 @@
if (keepField(tag, tags))
{
- TiffField entry = new TiffField(tag, type, length, valueOffset,
+ TiffField entry = new TiffField(tag, dirType, type, length, valueOffset,
valueOffsetBytes, getByteOrder());
result.add(entry);
- // Debug.debug("read field tag", tag + ", 0x"
- // + Integer.toHexString(tag));
+ // Debug.debug("read field tag", tag + ", 0x"
+ // + Integer.toHexString(tag));
if (debug)
for (int j = 0; j < 4; j++)
@@ -213,7 +215,7 @@
}
}
- Vector directories = new Vector();
+ ArrayList directories = new ArrayList();
int offset = tiffHeader.offsetToFirstIFD;
for (int count = 0; (offset > 0)
@@ -255,7 +257,7 @@
try
{
is = byteSource.getInputStream();
- // Debug.debug("readSingleDirectory offset", offset);
+ // Debug.debug("readSingleDirectory offset", offset);
if (offset > 0)
is.skip(offset);
@@ -292,14 +294,14 @@
if (contents == null)
throw new ImageReadException("TIFF missing contents");
- Vector directories = contents.directories;
+ ArrayList directories = contents.directories;
if ((directories == null) || (directories.size() < 1))
return null;
- // throw new ImageReadException("TIFF missing directories");
+ // throw new ImageReadException("TIFF missing directories");
TiffDirectory directory = (TiffDirectory) directories.get(0);
- Vector entries = directory.entries;
+ ArrayList entries = directory.entries;
if ((entries == null) || (entries.size() != 1))
throw new ImageReadException("TIFF missing entries");
@@ -310,14 +312,14 @@
}
- private TiffField findField(Vector directories, int tag)
+ private TiffField findField(ArrayList directories, int tag)
throws ImageReadException, IOException
{
if ((directories == null) || (directories.size() < 1))
throw new ImageReadException("TIFF missing directories");
TiffDirectory directory = (TiffDirectory) directories.get(0);
- Vector entries = directory.entries;
+ ArrayList entries = directory.entries;
if ((entries == null) || (entries.size() < 1))
throw new ImageReadException("TIFF missing entries");
@@ -332,7 +334,7 @@
return null;
}
- private TiffField findField(Vector entries, TagInfo tag)
+ private TiffField findField(ArrayList entries, TagInfo2 tag)
{
if (entries == null)
return null;
@@ -351,7 +353,7 @@
throws ImageReadException, IOException
{
int fieldTypes[] = new int[]{
- TIFF_TAG_ImageWidth.tag, TIFF_TAG_ImageLength.tag,
+ TIFF_TAG_IMAGE_WIDTH.tag, TIFF_TAG_IMAGE_LENGTH.tag,
};
TiffContents contents = readDirectories(byteSource, fieldTypes, -1, 2,
@@ -359,10 +361,11 @@
if (contents == null)
throw new ImageReadException("TIFF missing contents");
- Vector directories = contents.directories;
+ ArrayList directories = contents.directories;
- TiffField widthField = findField(directories, TIFF_TAG_ImageWidth.tag);
- TiffField heightField = findField(directories, TIFF_TAG_ImageLength.tag);
+ TiffField widthField = findField(directories, TIFF_TAG_IMAGE_WIDTH.tag);
+ TiffField heightField = findField(directories,
+ TIFF_TAG_IMAGE_LENGTH.tag);
if ((widthField == null) || (heightField == null))
throw new ImageReadException("TIFF image has invalid size.");
@@ -420,7 +423,7 @@
if (contents == null)
throw new ImageReadException("TIFF missing contents");
- Vector directories = contents.directories;
+ ArrayList directories = contents.directories;
TiffImageMetadata result = new TiffImageMetadata(contents);
@@ -445,9 +448,9 @@
}
if (dir.hasJpegImageData())
{
- // BufferedImage thumbnail = getBufferedImage(byteSource, dir,
- // null);
- // metadataDirectory.setThumbnail(thumbnail);
+ // BufferedImage thumbnail = getBufferedImage(byteSource, dir,
+ // null);
+ // metadataDirectory.setThumbnail(thumbnail);
byte rawJpegImageData[] = getJpegRawImageData(byteSource,
dir);
@@ -455,37 +458,37 @@
}
}
- Vector entries = dir.getDirectoryEntrys();
+ ArrayList entries = dir.getDirectoryEntrys();
for (int j = 0; j < entries.size(); j++)
{
TiffField entry = (TiffField) entries.get(j);
- if (entry.tag == TiffConstants.TIFF_TAG_Exif_IFD_Pointer.tag
- || entry.tag == TiffConstants.TIFF_TAG_GPSInfo_IFD_Pointer.tag
- || entry.tag == TiffConstants.TIFF_TAG_Interoperability_IFD_Pointer.tag)
+ if (entry.tag == TiffConstants.EXIF_TAG_EXIF_OFFSET.tag
+ || entry.tag == TiffConstants.EXIF_TAG_GPSINFO.tag
+ || entry.tag == TiffConstants.EXIF_TAG_INTEROP_OFFSET.tag)
{
int offset = ((Number) entry.getValue()).intValue();
int dirType;
- if (entry.tag == TiffConstants.TIFF_TAG_Exif_IFD_Pointer.tag)
+ if (entry.tag == TiffConstants.EXIF_TAG_EXIF_OFFSET.tag)
dirType = TiffDirectory.DIRECTORY_TYPE_EXIF;
- else if (entry.tag == TiffConstants.TIFF_TAG_GPSInfo_IFD_Pointer.tag)
+ else if (entry.tag == TiffConstants.EXIF_TAG_GPSINFO.tag)
dirType = TiffDirectory.DIRECTORY_TYPE_GPS;
- else if (entry.tag == TiffConstants.TIFF_TAG_Interoperability_IFD_Pointer.tag)
+ else if (entry.tag == TiffConstants.EXIF_TAG_INTEROP_OFFSET.tag)
dirType = TiffDirectory.DIRECTORY_TYPE_INTEROPERABILITY;
else
throw new ImageReadException(
"Unknown subdirectory type.");
- // Debug.debug();
- // Debug.debug("extra dir child of ", dir.description());
- // Debug.debug("extra dir offset", offset);
- // Debug.debug("extra dir type", TiffDirectory.description(dirType));
+ // Debug.debug();
+ // Debug.debug("extra dir child of ", dir.description());
+ // Debug.debug("extra dir offset", offset);
+ // Debug.debug("extra dir type", TiffDirectory.description(dirType));
TiffDirectory extraDir = readSingleDirectory(byteSource,
dirType, offset, getDefaultFormatCompliance());
- // Debug.debug("extraDir", extraDir);
- // directories.add(extraDir);
- directories.insertElementAt(extraDir, i + 1);
+ // Debug.debug("extraDir", extraDir);
+ // directories.add(extraDir);
+ directories.add(i + 1, extraDir);
}
metadataDirectory.add(entry);
@@ -616,11 +619,11 @@
throws ImageReadException, IOException
{
int FieldTypes[] = new int[]{
- TIFF_TAG_ImageWidth.tag, TIFF_TAG_ImageLength.tag,
- TIFF_TAG_ResolutionUnit.tag, TIFF_TAG_XResolution.tag,
- TIFF_TAG_YResolution.tag, TIFF_TAG_BitsPerSample.tag,
- TIFF_TAG_ColorMap.tag, TIFF_TAG_SamplesPerPixel.tag,
- TIFF_TAG_Compression.tag,
+ TIFF_TAG_IMAGE_WIDTH.tag, TIFF_TAG_IMAGE_LENGTH.tag,
+ TIFF_TAG_RESOLUTION_UNIT.tag, TIFF_TAG_XRESOLUTION.tag,
+ TIFF_TAG_YRESOLUTION.tag, TIFF_TAG_BITS_PER_SAMPLE.tag,
+ TIFF_TAG_COLOR_MAP.tag, TIFF_TAG_SAMPLES_PER_PIXEL.tag,
+ TIFF_TAG_COMPRESSION.tag,
};
TiffContents contents = readDirectories(byteSource, FieldTypes, -1, -1,
@@ -628,19 +631,19 @@
if (contents == null)
throw new ImageReadException("TIFF missing contents");
- Vector dirs = contents.directories;
+ ArrayList dirs = contents.directories;
if ((dirs == null) || (dirs.size() < 1))
throw new ImageReadException("TIFF image missing directories");
TiffDirectory directory = (TiffDirectory) dirs.get(0);
- Vector entries = directory.entries;
+ ArrayList entries = directory.entries;
if (entries == null)
throw new ImageReadException("TIFF missing entries");
- TiffField widthField = findField(entries, TIFF_TAG_ImageWidth);
- TiffField heightField = findField(entries, TIFF_TAG_ImageLength);
+ TiffField widthField = findField(entries, TIFF_TAG_IMAGE_WIDTH);
+ TiffField heightField = findField(entries, TIFF_TAG_IMAGE_LENGTH);
if ((widthField == null) || (heightField == null))
throw new ImageReadException("TIFF image missing size info.");
@@ -651,7 +654,7 @@
//-------------------
TiffField resolutionUnitField = findField(entries,
- TIFF_TAG_ResolutionUnit);
+ TIFF_TAG_RESOLUTION_UNIT);
int resolutionUnit = 2; // Inch
if ((resolutionUnitField != null)
&& (resolutionUnitField.getValue() != null))
@@ -674,8 +677,8 @@
break;
}
- TiffField xResolutionField = findField(entries, TIFF_TAG_XResolution);
- TiffField yResolutionField = findField(entries, TIFF_TAG_YResolution);
+ TiffField xResolutionField = findField(entries, TIFF_TAG_XRESOLUTION);
+ TiffField yResolutionField = findField(entries, TIFF_TAG_YRESOLUTION);
int physicalWidthDpi = -1;
float physicalWidthInch = -1;
@@ -705,9 +708,9 @@
//-------------------
TiffField bitsPerSampleField = findField(entries,
- TIFF_TAG_BitsPerSample);
-// TiffField samplesPerPixelField = findField(entries,
-// TIFF_TAG_SamplesPerPixel);
+ TIFF_TAG_BITS_PER_SAMPLE);
+ // TiffField samplesPerPixelField = findField(entries,
+ // TIFF_TAG_SAMPLES_PER_PIXEL);
int bitsPerSample = -1;
@@ -722,7 +725,7 @@
//-------------------
- Vector comments = new Vector();
+ ArrayList comments = new ArrayList();
for (int i = 0; i < entries.size(); i++)
{
TiffField field = (TiffField) entries.get(i);
@@ -743,13 +746,13 @@
boolean isTransparent = false; // TODO: wrong
boolean usesPalette = false;
- TiffField colorMapField = findField(entries, TIFF_TAG_ColorMap);
+ TiffField colorMapField = findField(entries, TIFF_TAG_COLOR_MAP);
if (colorMapField != null)
usesPalette = true;
int colorType = ImageInfo.COLOR_TYPE_RGB;
- int compression = getTagAsNumber(entries, TIFF_TAG_Compression)
+ int compression = getTagAsNumber(entries, TIFF_TAG_COMPRESSION)
.intValue();
String compressionAlgorithm;
@@ -815,7 +818,7 @@
if (contents == null)
return false;
- Vector directories = contents.directories;
+ ArrayList directories = contents.directories;
if (directories == null)
return false;
@@ -824,7 +827,7 @@
{
TiffDirectory directory = (TiffDirectory) directories.get(d);
- Vector entries = directory.entries;
+ ArrayList entries = directory.entries;
if (entries == null)
return false;
@@ -852,7 +855,7 @@
return true;
}
- private Number getTagAsNumber(Vector entries, TagInfo tag)
+ private Number getTagAsNumber(ArrayList entries, TagInfo2 tag)
throws ImageReadException, IOException
{
TiffField entry = findField(entries, tag);
@@ -862,8 +865,8 @@
Object o = entry.getValue();
- // Debug.debug("getTagAsNumber:" + entry.tagInfo.name, o);
- // Debug.debug("getTagAsNumber:" + entry.tagInfo.name, Debug.getType(o));
+ // Debug.debug("getTagAsNumber:" + entry.tagInfo.name, o);
+ // Debug.debug("getTagAsNumber:" + entry.tagInfo.name, Debug.getType(o));
Number result = (Number) o;
@@ -874,7 +877,7 @@
return result;
}
- private int getTagAsValueOrArraySum(Vector entries, TagInfo tag)
+ private int getTagAsValueOrArraySum(ArrayList entries, TagInfo2 tag)
throws ImageReadException, IOException
{
TiffField entry = findField(entries, tag);
@@ -890,7 +893,7 @@
return result;
}
- private double[] getTagAsDoubleArray(Vector entries, TagInfo tag,
+ private double[] getTagAsDoubleArray(ArrayList entries, TagInfo2 tag,
boolean throwExceptionIfMissing) throws ImageReadException,
IOException
{
@@ -909,7 +912,7 @@
return result;
}
- private int[] getTagAsIntArray(Vector entries, TagInfo tag,
+ private int[] getTagAsIntArray(ArrayList entries, TagInfo2 tag,
boolean throwExceptionIfMissing) throws ImageReadException,
IOException
{
@@ -931,7 +934,7 @@
return result;
}
- private int dumpOptionalNumberTag(Vector entries, TagInfo tag)
+ private int dumpOptionalNumberTag(ArrayList entries, TagInfo2 tag)
{
TiffField entry = findField(entries, tag);
@@ -941,9 +944,7 @@
if (o instanceof Number)
{
int value = ((Number) o).intValue();
- if (debug) {
- System.out.println(tag.name + ": " + value);
- }
+ // System.out.println(tag.name + ": " + value);
return value;
}
}
@@ -969,7 +970,7 @@
if (contents == null)
throw new ImageReadException("TIFF missing contents");
- Vector directories = contents.directories;
+ ArrayList directories = contents.directories;
if ((directories == null) || (directories.size() < 1))
throw new ImageReadException("TIFF missing TiffDirectories");
@@ -982,7 +983,7 @@
public RawTiffImageData getTiffRawImageData(ByteSource byteSource,
TiffDirectory directory) throws ImageReadException, IOException
{
- Vector elements = directory.getTiffRawImageDataElements();
+ ArrayList elements = directory.getTiffRawImageDataElements();
byte result[][] = new byte[elements.size()][];
for (int i = 0; i < elements.size(); i++)
{
@@ -1009,50 +1010,50 @@
TiffDirectory directory, Map params) throws ImageReadException,
IOException
{
- Vector entries = directory.entries;
+ ArrayList entries = directory.entries;
if (entries == null)
throw new ImageReadException("TIFF missing entries");
- // this.setDebug(true);
+ // this.setDebug(true);
- TiffField imageWidthField = findField(entries, TIFF_TAG_ImageWidth);
+ TiffField imageWidthField = findField(entries, TIFF_TAG_IMAGE_WIDTH);
if (imageWidthField == null)
throw new ImageReadException(
- "Tiff: Missing Tag: TIFF_TAG_ImageWidth");
- TiffField imageLengthField = findField(entries, TIFF_TAG_ImageLength);
+ "Tiff: Missing Tag: TIFF_TAG_IMAGE_WIDTH");
+ TiffField imageLengthField = findField(entries, TIFF_TAG_IMAGE_LENGTH);
if (imageLengthField == null)
throw new ImageReadException(
- "Tiff: Missing Tag: TIFF_TAG_ImageLength");
+ "Tiff: Missing Tag: TIFF_TAG_IMAGE_LENGTH");
int photometricInterpretation = getTagAsNumber(entries,
- TIFF_TAG_PhotometricInterpretation).intValue();
- int compression = getTagAsNumber(entries, TIFF_TAG_Compression)
- .intValue();
- int width = getTagAsNumber(entries, TIFF_TAG_ImageWidth).intValue();
- int height = getTagAsNumber(entries, TIFF_TAG_ImageLength).intValue();
- int samplesPerPixel = getTagAsNumber(entries, TIFF_TAG_SamplesPerPixel)
+ TIFF_TAG_PHOTOMETRIC_INTERPRETATION).intValue();
+ int compression = getTagAsNumber(entries, TIFF_TAG_COMPRESSION)
.intValue();
- int bitsPerSample[] = getTagAsIntArray(entries, TIFF_TAG_BitsPerSample,
- true);
+ int width = getTagAsNumber(entries, TIFF_TAG_IMAGE_WIDTH).intValue();
+ int height = getTagAsNumber(entries, TIFF_TAG_IMAGE_LENGTH).intValue();
+ int samplesPerPixel = getTagAsNumber(entries,
+ TIFF_TAG_SAMPLES_PER_PIXEL).intValue();
+ int bitsPerSample[] = getTagAsIntArray(entries,
+ TIFF_TAG_BITS_PER_SAMPLE, true);
int bitsPerPixel = getTagAsValueOrArraySum(entries,
- TIFF_TAG_BitsPerSample);
+ TIFF_TAG_BITS_PER_SAMPLE);
int predictor;
{
- dumpOptionalNumberTag(entries, TIFF_TAG_FillOrder);
- dumpOptionalNumberTag(entries, TIFF_TAG_FreeByteCounts);
- dumpOptionalNumberTag(entries, TIFF_TAG_FreeOffsets);
- dumpOptionalNumberTag(entries, TIFF_TAG_Orientation);
- dumpOptionalNumberTag(entries, TIFF_TAG_PlanarConfiguration);
- predictor = dumpOptionalNumberTag(entries, TIFF_TAG_Predictor);
+ // dumpOptionalNumberTag(entries, TIFF_TAG_FILL_ORDER);
+ // dumpOptionalNumberTag(entries, TIFF_TAG_FREE_BYTE_COUNTS);
+ // dumpOptionalNumberTag(entries, TIFF_TAG_FREE_OFFSETS);
+ // dumpOptionalNumberTag(entries, TIFF_TAG_ORIENTATION);
+ // dumpOptionalNumberTag(entries, TIFF_TAG_PLANAR_CONFIGURATION);
+ predictor = dumpOptionalNumberTag(entries, TIFF_TAG_PREDICTOR);
}
if (samplesPerPixel != bitsPerSample.length)
throw new ImageReadException("Tiff: fSamplesPerPixel ("
+ samplesPerPixel + ")!=fBitsPerSample.length ("
+ bitsPerSample.length + ")");
-
+
boolean hasAlpha = false;
BufferedImage result = getBufferedImageFactory(params)
.getColorBufferedImage(width, height, hasAlpha);
@@ -1061,7 +1062,7 @@
entries, photometricInterpretation, bitsPerPixel,
bitsPerSample, predictor, samplesPerPixel, width, height);
- // this.setDebug(false);
+ // this.setDebug(false);
DataReader dataReader = getDataReader(entries, photometricInterpreter,
bitsPerPixel, bitsPerSample, predictor, samplesPerPixel, width,
@@ -1074,7 +1075,7 @@
return result;
}
- private PhotometricInterpreter getPhotometricInterpreter(Vector entries,
+ private PhotometricInterpreter getPhotometricInterpreter(ArrayList entries,
int photometricInterpretation, int bitsPerPixel,
int bitsPerSample[], int predictor, int samplesPerPixel, int width,
int height) throws IOException, ImageReadException
@@ -1090,7 +1091,7 @@
height, invert);
case 3 : // Palette
{
- int[] colorMap = getTagAsIntArray(entries, TIFF_TAG_ColorMap,
+ int[] colorMap = getTagAsIntArray(entries, TIFF_TAG_COLOR_MAP,
false);
int expected_colormap_size = 3 * (1 << bitsPerPixel);
@@ -1112,13 +1113,13 @@
case 6 : //
{
double[] fYCbCrCoefficients = getTagAsDoubleArray(entries,
- TIFF_TAG_YCbCrCoefficients, false);
+ TIFF_TAG_YCBCR_COEFFICIENTS, false);
int[] fYCbCrPositioning = getTagAsIntArray(entries,
- TIFF_TAG_YCbCrPositioning, false);
+ TIFF_TAG_YCBCR_POSITIONING, false);
int[] fYCbCrSubSampling = getTagAsIntArray(entries,
- TIFF_TAG_YCbCrSubSampling, false);
+ TIFF_TAG_YCBCR_SUB_SAMPLING, false);
double[] referenceBlackWhite = getTagAsDoubleArray(entries,
- TIFF_TAG_ReferenceBlackWhite, false);
+ TIFF_TAG_REFERENCE_BLACK_WHITE, false);
return new PhotometricInterpreterYCbCr(fYCbCrCoefficients,
fYCbCrPositioning, fYCbCrSubSampling,
@@ -1144,23 +1145,23 @@
}
}
- private DataReader getDataReader(Vector entries,
+ private DataReader getDataReader(ArrayList entries,
PhotometricInterpreter photometricInterpreter, int bitsPerPixel,
int bitsPerSample[], int predictor, int samplesPerPixel, int width,
int height, int compression) throws IOException, ImageReadException
{
- int[] tileOffsets = getTagAsIntArray(entries, TIFF_TAG_TileOffsets,
+ int[] tileOffsets = getTagAsIntArray(entries, TIFF_TAG_TILE_OFFSETS,
false);
int[] tileByteCounts = getTagAsIntArray(entries,
- TIFF_TAG_TileByteCounts, false);
+ TIFF_TAG_TILE_BYTE_COUNTS, false);
- int[] stripOffsets = getTagAsIntArray(entries, TIFF_TAG_StripOffsets,
+ int[] stripOffsets = getTagAsIntArray(entries, TIFF_TAG_STRIP_OFFSETS,
false);
int[] stripByteCounts = getTagAsIntArray(entries,
- TIFF_TAG_StripByteCounts, false);
+ TIFF_TAG_STRIP_BYTE_COUNTS, false);
- TiffField tileWidthField = findField(entries, TIFF_TAG_TileWidth);
- TiffField tileLengthField = findField(entries, TIFF_TAG_TileLength);
+ TiffField tileWidthField = findField(entries, TIFF_TAG_TILE_WIDTH);
+ TiffField tileLengthField = findField(entries, TIFF_TAG_TILE_LENGTH);
if ((tileOffsets != null) && (tileByteCounts != null))
{
@@ -1169,9 +1170,9 @@
+ tileOffsets.length + ")!=fTileByteCounts.length ("
+ tileByteCounts.length + ")");
- int tileWidth = getTagAsNumber(entries, TIFF_TAG_TileWidth)
+ int tileWidth = getTagAsNumber(entries, TIFF_TAG_TILE_WIDTH)
.intValue();
- int tileLength = getTagAsNumber(entries, TIFF_TAG_TileLength)
+ int tileLength = getTagAsNumber(entries, TIFF_TAG_TILE_LENGTH)
.intValue();
return new DataReaderTiled(photometricInterpreter, tileOffsets,
@@ -1187,9 +1188,9 @@
+ stripOffsets.length + ")!=fStripByteCounts.length ("
+ stripByteCounts.length + ")");
- int tileWidth = getTagAsNumber(entries, TIFF_TAG_TileWidth)
+ int tileWidth = getTagAsNumber(entries, TIFF_TAG_TILE_WIDTH)
.intValue();
- int tileLength = getTagAsNumber(entries, TIFF_TAG_TileLength)
+ int tileLength = getTagAsNumber(entries, TIFF_TAG_TILE_LENGTH)
.intValue();
return new DataReaderTiled(photometricInterpreter, stripOffsets,
@@ -1199,7 +1200,7 @@
}
else if ((stripOffsets != null) && (stripByteCounts != null))
{
- int rowsPerStrip = getTagAsNumber(entries, TIFF_TAG_RowsPerStrip)
+ int rowsPerStrip = getTagAsNumber(entries, TIFF_TAG_ROWS_PER_STRIP)
.intValue();
if (stripOffsets.length != stripByteCounts.length)
@@ -1222,4 +1223,4 @@
new TiffImageWriter().writeImage(src, os, params);
}
-}
\ No newline at end of file
+}
Added: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/constants/AllTagConstants.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/constants/AllTagConstants.java?rev=607388&view=auto
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/constants/AllTagConstants.java (added)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/constants/AllTagConstants.java Fri Dec 28 22:48:44 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.tiff.constants;
+
+import org.apache.sanselan.SanselanConstants;
+
+public interface AllTagConstants
+ extends
+ SanselanConstants,
+ TiffTagConstants,
+ ExifTagConstants,
+ GPSTagConstants
+{
+ public static final TagInfo2 ALL_TAGS[] = TagConstantsUtils
+ .mergeTagLists(new TagInfo2[][]{
+ ALL_TIFF_TAGS, ALL_EXIF_TAGS, ALL_GPS_TAGS,
+ });
+
+}
\ No newline at end of file
Propchange: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/constants/AllTagConstants.java
------------------------------------------------------------------------------
svn:eol-style = native