commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1445822 [3/3] - in /commons/proper/imaging/trunk/src: main/java/org/apache/commons/imaging/common/ main/java/org/apache/commons/imaging/common/bytesource/ main/java/org/apache/commons/imaging/common/mylzw/ main/java/org/apache/commons/imag...
Date Wed, 13 Feb 2013 18:40:53 GMT
Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java?rev=1445822&r1=1445821&r2=1445822&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java
Wed Feb 13 18:40:52 2013
@@ -70,16 +70,16 @@ public class TiffImageWriterLossless ext
                 final TiffDirectory directory = directories.get(d);
                 elements.add(directory);
 
-                final List<TiffField> fields = directory.getDirectoryEntrys();
+                final List<TiffField> fields = directory.getDirectoryEntries();
                 for (int f = 0; f < fields.size(); f++) {
                     final TiffField field = fields.get(f);
                     final TiffElement oversizeValue = field.getOversizeValueElement();
                     if (oversizeValue != null) {
-                        final TiffOutputField frozenField = frozenFields.get(field.tag);
+                        final TiffOutputField frozenField = frozenFields.get(field.getTag());
                         if (frozenField != null &&
                                 frozenField.getSeperateValue() != null &&
                                 frozenField.bytesEqual(field.getByteArrayValue())) {
-                            frozenField.getSeperateValue().setOffset(field.valueOffset);
+                            frozenField.getSeperateValue().setOffset(field.getOffset());
                         } else {
                             elements.add(oversizeValue);
                         }
@@ -110,16 +110,16 @@ public class TiffImageWriterLossless ext
                 final int TOLERANCE = 3;
                 // int last = TIFF_HEADER_SIZE;
                 TiffElement start = null;
-                int index = -1;
+                long index = -1;
                 for (int i = 0; i < elements.size(); i++) {
                     final TiffElement element = elements.get(i);
-                    final int lastElementByte = element.offset + element.length;
+                    final long lastElementByte = element.offset + element.length;
                     if (start == null) {
                         start = element;
                         index = lastElementByte;
                     } else if (element.offset - index > TOLERANCE) {
-                        rewritableElements.add(new TiffElement.Stub(start.offset, index
-                                - start.offset));
+                        rewritableElements.add(new TiffElement.Stub(start.offset,
+                                (int) (index - start.offset)));
                         start = element;
                         index = lastElementByte;
                     } else {
@@ -127,8 +127,8 @@ public class TiffImageWriterLossless ext
                     }
                 }
                 if (null != start) {
-                    rewritableElements.add(new TiffElement.Stub(start.offset, index
-                            - start.offset));
+                    rewritableElements.add(new TiffElement.Stub(start.offset,
+                            (int) (index - start.offset)));
                 }
             }
 
@@ -164,7 +164,7 @@ public class TiffImageWriterLossless ext
                 return;
             }
         }
-        final Map<Integer,TiffOutputField> frozenFieldOffsets = new HashMap<Integer,
TiffOutputField>();
+        final Map<Long,TiffOutputField> frozenFieldOffsets = new HashMap<Long, TiffOutputField>();
         for (Map.Entry<Integer,TiffOutputField> entry : frozenFields.entrySet()) {
             final TiffOutputField frozenField = entry.getValue();
             if (frozenField.getSeperateValue().getOffset() != TiffOutputItem.UNDEFINED_VALUE)
{
@@ -183,7 +183,7 @@ public class TiffImageWriterLossless ext
             }
         }
 
-        final int outputLength = updateOffsetsStep(analysis, outputItems);
+        final long outputLength = updateOffsetsStep(analysis, outputItems);
 
         outputSummary.updateOffsets(byteOrder);
 
@@ -203,10 +203,10 @@ public class TiffImageWriterLossless ext
         }
     };
 
-    private int updateOffsetsStep(final List<TiffElement> analysis,
+    private long updateOffsetsStep(final List<TiffElement> analysis,
             final List<TiffOutputItem> outputItems) {
         // items we cannot fit into a gap, we shall append to tail.
-        int overflowIndex = exifBytes.length;
+        long overflowIndex = exifBytes.length;
 
         // make copy.
         final List<TiffElement> unusedElements = new ArrayList<TiffElement>(analysis);
@@ -218,7 +218,7 @@ public class TiffImageWriterLossless ext
         // discarded.
         while (unusedElements.size() > 0) {
             final TiffElement element = unusedElements.get(0);
-            final int elementEnd = element.offset + element.length;
+            final long elementEnd = element.offset + element.length;
             if (elementEnd == overflowIndex) {
                 // discarding a tail element. should only happen once.
                 overflowIndex -= element.length;
@@ -262,7 +262,7 @@ public class TiffImageWriterLossless ext
 
                 if (bestFit.length > outputItemLength) {
                     // not a perfect fit.
-                    final int excessOffset = bestFit.offset + outputItemLength;
+                    final long excessOffset = bestFit.offset + outputItemLength;
                     final int excessLength = bestFit.length - outputItemLength;
                     unusedElements.add(new TiffElement.Stub(excessOffset,
                             excessLength));
@@ -306,10 +306,10 @@ public class TiffImageWriterLossless ext
 
     private void writeStep(final OutputStream os, final TiffOutputSet outputSet,
             final List<TiffElement> analysis, final List<TiffOutputItem> outputItems,
-            final int outputLength) throws IOException, ImageWriteException {
+            final long outputLength) throws IOException, ImageWriteException {
         final TiffOutputDirectory rootDirectory = outputSet.getRootDirectory();
 
-        final byte output[] = new byte[outputLength];
+        final byte output[] = new byte[(int)outputLength];
 
         // copy old data (including maker notes, etc.)
         System.arraycopy(exifBytes, 0, output, 0,
@@ -329,7 +329,7 @@ public class TiffImageWriterLossless ext
         for (int i = 0; i < analysis.size(); i++) {
             final TiffElement element = analysis.get(i);
             for (int j = 0; j < element.length; j++) {
-                final int index = element.offset + j;
+                final int index = (int)(element.offset + j);
                 if (index < output.length) {
                     output[index] = 0;
                 }
@@ -341,7 +341,7 @@ public class TiffImageWriterLossless ext
             final TiffOutputItem outputItem = outputItems.get(i);
 
             final BufferOutputStream tos = new BufferOutputStream(output,
-                    outputItem.getOffset());
+                    (int)outputItem.getOffset());
             final BinaryOutputStream bos = new BinaryOutputStream(tos, byteOrder);
             outputItem.writeItem(bos);
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java?rev=1445822&r1=1445821&r2=1445822&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java
Wed Feb 13 18:40:52 2013
@@ -33,7 +33,6 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.constants.TagConstantsUtils;
 import org.apache.commons.imaging.formats.tiff.constants.TiffConstants;
 import org.apache.commons.imaging.formats.tiff.constants.TiffDirectoryType;
-import org.apache.commons.imaging.formats.tiff.constants.TiffFieldTypeConstants;
 import org.apache.commons.imaging.formats.tiff.constants.TiffTagConstants;
 import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType;
 import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo;
@@ -92,7 +91,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_BYTE, values.length,
+                tagInfo, FieldType.BYTE, values.length,
                 bytes);
         add(tiffOutputField);
     }
@@ -105,7 +104,7 @@ public final class TiffOutputDirectory e
                     + " byte(s), not " + values.length);
         }
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_ASCII, bytes.length,
+                tagInfo, FieldType.ASCII, bytes.length,
                 bytes);
         add(tiffOutputField);
     }
@@ -118,7 +117,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_SHORT,
+                tagInfo, FieldType.SHORT,
                 values.length, bytes);
         add(tiffOutputField);
     }
@@ -131,7 +130,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_LONG, values.length,
+                tagInfo, FieldType.LONG, values.length,
                 bytes);
         add(tiffOutputField);
     }
@@ -144,7 +143,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_RATIONAL,
+                tagInfo, FieldType.RATIONAL,
                 values.length, bytes);
         add(tiffOutputField);
     }
@@ -157,7 +156,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_SBYTE,
+                tagInfo, FieldType.SBYTE,
                 values.length, bytes);
         add(tiffOutputField);
     }
@@ -170,7 +169,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_SSHORT,
+                tagInfo, FieldType.SSHORT,
                 values.length, bytes);
         add(tiffOutputField);
     }
@@ -183,7 +182,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_SLONG,
+                tagInfo, FieldType.SLONG,
                 values.length, bytes);
         add(tiffOutputField);
     }
@@ -196,7 +195,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_SRATIONAL,
+                tagInfo, FieldType.SRATIONAL,
                 values.length, bytes);
         add(tiffOutputField);
     }
@@ -209,7 +208,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_FLOAT,
+                tagInfo, FieldType.FLOAT,
                 values.length, bytes);
         add(tiffOutputField);
     }
@@ -222,7 +221,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_DOUBLE,
+                tagInfo, FieldType.DOUBLE,
                 values.length, bytes);
         add(tiffOutputField);
     }
@@ -235,7 +234,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_BYTE, values.length,
+                tagInfo, FieldType.BYTE, values.length,
                 bytes);
         add(tiffOutputField);
     }
@@ -248,7 +247,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_SHORT,
+                tagInfo, FieldType.SHORT,
                 values.length, bytes);
         add(tiffOutputField);
     }
@@ -261,7 +260,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_SHORT,
+                tagInfo, FieldType.SHORT,
                 values.length, bytes);
         add(tiffOutputField);
     }
@@ -274,7 +273,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_LONG, values.length,
+                tagInfo, FieldType.LONG, values.length,
                 bytes);
         add(tiffOutputField);
     }
@@ -287,7 +286,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_SHORT,
+                tagInfo, FieldType.SHORT,
                 values.length, bytes);
         add(tiffOutputField);
     }
@@ -300,7 +299,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_LONG, values.length,
+                tagInfo, FieldType.LONG, values.length,
                 bytes);
         add(tiffOutputField);
     }
@@ -313,7 +312,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_RATIONAL,
+                tagInfo, FieldType.RATIONAL,
                 values.length, bytes);
         add(tiffOutputField);
     }
@@ -326,7 +325,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_SHORT,
+                tagInfo, FieldType.SHORT,
                 values.length, bytes);
         add(tiffOutputField);
     }
@@ -339,7 +338,7 @@ public final class TiffOutputDirectory e
         }
         final byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_RATIONAL,
+                tagInfo, FieldType.RATIONAL,
                 values.length, bytes);
         add(tiffOutputField);
     }
@@ -347,7 +346,7 @@ public final class TiffOutputDirectory e
     public void add(final TagInfoGpsText tagInfo, final String value)
             throws ImageWriteException {
         final byte[] bytes = tagInfo.encodeValue(
-                TiffFieldTypeConstants.FIELD_TYPE_UNKNOWN, value, byteOrder);
+                FieldType.UNDEFINED, value, byteOrder);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
                 tagInfo, tagInfo.dataTypes.get(0), bytes.length, bytes);
         add(tiffOutputField);
@@ -356,9 +355,9 @@ public final class TiffOutputDirectory e
     public void add(final TagInfoXpString tagInfo, final String value)
             throws ImageWriteException {
         final byte[] bytes = tagInfo.encodeValue(
-                TiffFieldTypeConstants.FIELD_TYPE_BYTE, value, byteOrder);
+                FieldType.BYTE, value, byteOrder);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_BYTE, bytes.length,
+                tagInfo, FieldType.BYTE, bytes.length,
                 bytes);
         add(tiffOutputField);
     }
@@ -366,13 +365,13 @@ public final class TiffOutputDirectory e
     public void add(final TagInfoAsciiOrByte tagInfo, final String... values)
             throws ImageWriteException {
         final byte[] bytes = tagInfo.encodeValue(
-                TiffFieldTypeConstants.FIELD_TYPE_ASCII, values, byteOrder);
+                FieldType.ASCII, values, byteOrder);
         if (tagInfo.length > 0 && tagInfo.length != bytes.length) {
             throw new ImageWriteException("Tag expects " + tagInfo.length
                     + " byte(s), not " + values.length);
         }
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_ASCII, bytes.length,
+                tagInfo, FieldType.ASCII, bytes.length,
                 bytes);
         add(tiffOutputField);
     }
@@ -380,13 +379,13 @@ public final class TiffOutputDirectory e
     public void add(final TagInfoAsciiOrRational tagInfo, final String... values)
             throws ImageWriteException {
         final byte[] bytes = tagInfo.encodeValue(
-                TiffFieldTypeConstants.FIELD_TYPE_ASCII, values, byteOrder);
+                FieldType.ASCII, values, byteOrder);
         if (tagInfo.length > 0 && tagInfo.length != bytes.length) {
             throw new ImageWriteException("Tag expects " + tagInfo.length
                     + " byte(s), not " + values.length);
         }
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_ASCII, bytes.length,
+                tagInfo, FieldType.ASCII, bytes.length,
                 bytes);
         add(tiffOutputField);
     }
@@ -398,9 +397,9 @@ public final class TiffOutputDirectory e
                     + " value(s), not " + values.length);
         }
         final byte[] bytes = tagInfo.encodeValue(
-                TiffFieldTypeConstants.FIELD_TYPE_RATIONAL, values, byteOrder);
+                FieldType.RATIONAL, values, byteOrder);
         final TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag,
-                tagInfo, TiffFieldTypeConstants.FIELD_TYPE_RATIONAL,
+                tagInfo, FieldType.RATIONAL,
                 bytes.length, bytes);
         add(tiffOutputField);
     }
@@ -475,7 +474,7 @@ public final class TiffOutputDirectory e
             // Debug.debug("\t\tOFFSET!", field.bytes);
         }
 
-        int nextDirectoryOffset = 0;
+        long nextDirectoryOffset = 0;
         if (nextDirectory != null) {
             nextDirectoryOffset = nextDirectory.getOffset();
         }
@@ -484,7 +483,7 @@ public final class TiffOutputDirectory e
         if (nextDirectoryOffset == UNDEFINED_VALUE) {
             bos.write4Bytes(0);
         } else {
-            bos.write4Bytes(nextDirectoryOffset);
+            bos.write4Bytes((int)nextDirectoryOffset);
         }
     }
 
@@ -539,16 +538,16 @@ public final class TiffOutputDirectory e
         if (null != jpegImageData) {
             jpegOffsetField = new TiffOutputField(
                     TiffTagConstants.TIFF_TAG_JPEG_INTERCHANGE_FORMAT,
-                    FIELD_TYPE_LONG, 1, FieldType.getStubLocalValue());
+                    FieldType.LONG, 1, new byte[TIFF_ENTRY_MAX_VALUE_LENGTH]);
             add(jpegOffsetField);
 
-            final byte lengthValue[] = FIELD_TYPE_LONG.writeData(
-                    new int[] { jpegImageData.length, },
+            final byte lengthValue[] = FieldType.LONG.writeData(
+                    jpegImageData.length,
                     outputSummary.byteOrder);
 
             final TiffOutputField jpegLengthField = new TiffOutputField(
                     TiffTagConstants.TIFF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH,
-                    FIELD_TYPE_LONG, 1, lengthValue);
+                    FieldType.LONG, 1, lengthValue);
             add(jpegLengthField);
 
         }
@@ -593,17 +592,17 @@ public final class TiffOutputDirectory e
 
             // Append imageData-related fields to first directory
             imageDataOffsetField = new TiffOutputField(offsetTag,
-                    FIELD_TYPE_LONG, imageDataOffsets.length,
-                    FIELD_TYPE_LONG.writeData(imageDataOffsets,
+                    FieldType.LONG, imageDataOffsets.length,
+                    FieldType.LONG.writeData(imageDataOffsets,
                             outputSummary.byteOrder));
             add(imageDataOffsetField);
 
             // --------
 
-            final byte data[] = FIELD_TYPE_LONG.writeData(imageDataByteCounts,
+            final byte data[] = FieldType.LONG.writeData(imageDataByteCounts,
                     outputSummary.byteOrder);
             final TiffOutputField byteCountsField = new TiffOutputField(
-                    byteCountsTag, FIELD_TYPE_LONG, imageDataByteCounts.length,
+                    byteCountsTag, FieldType.LONG, imageDataByteCounts.length,
                     data);
             add(byteCountsField);
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputField.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputField.java?rev=1445822&r1=1445821&r2=1445822&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputField.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputField.java
Wed Feb 13 18:40:52 2013
@@ -62,14 +62,14 @@ public class TiffOutputField implements 
 
     protected static final TiffOutputField createOffsetField(final TagInfo tagInfo,
             final ByteOrder byteOrder) throws ImageWriteException {
-        return new TiffOutputField(tagInfo, FIELD_TYPE_LONG, 1,
-                FIELD_TYPE_LONG.writeData(new int[] { 0, }, byteOrder));
+        return new TiffOutputField(tagInfo, FieldType.LONG, 1,
+                FieldType.LONG.writeData(0, byteOrder));
     }
 
     protected void writeField(final BinaryOutputStream bos) throws IOException,
             ImageWriteException {
         bos.write2Bytes(tag);
-        bos.write2Bytes(fieldType.type);
+        bos.write2Bytes(fieldType.getType());
         bos.write4Bytes(count);
 
         if (isLocalValue()) {
@@ -91,7 +91,7 @@ public class TiffOutputField implements 
                 throw new ImageWriteException("Missing separate value item.");
             }
 
-            bos.write4Bytes(separateValueItem.getOffset());
+            bos.write4Bytes((int)separateValueItem.getOffset());
         }
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputItem.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputItem.java?rev=1445822&r1=1445821&r2=1445822&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputItem.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputItem.java
Wed Feb 13 18:40:52 2013
@@ -23,15 +23,15 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.formats.tiff.constants.AllTagConstants;
 
 abstract class TiffOutputItem implements AllTagConstants {
-    public static final int UNDEFINED_VALUE = -1;
+    public static final long UNDEFINED_VALUE = -1;
 
-    private int offset = UNDEFINED_VALUE;
+    private long offset = UNDEFINED_VALUE;
 
-    protected int getOffset() {
+    protected long getOffset() {
         return offset;
     }
 
-    protected void setOffset(final int offset) {
+    protected void setOffset(final long offset) {
         this.offset = offset;
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSummary.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSummary.java?rev=1445822&r1=1445821&r2=1445822&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSummary.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSummary.java
Wed Feb 13 18:40:52 2013
@@ -23,6 +23,7 @@ import java.util.Map;
 import org.apache.commons.imaging.ImageWriteException;
 import org.apache.commons.imaging.common.ByteOrder;
 import org.apache.commons.imaging.formats.tiff.constants.TiffConstants;
+import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType;
 
 class TiffOutputSummary implements TiffConstants {
     public final ByteOrder byteOrder;
@@ -60,8 +61,8 @@ class TiffOutputSummary implements TiffC
         for (int i = 0; i < offsetItems.size(); i++) {
             final OffsetItem offset = offsetItems.get(i);
 
-            final byte value[] = FIELD_TYPE_LONG.writeData(
-                    new int[] { offset.item.getOffset(), }, byteOrder);
+            final byte value[] = FieldType.LONG.writeData(
+                    (int)offset.item.getOffset(), byteOrder);
             offset.itemOffsetField.setData(value);
         }
 
@@ -70,10 +71,10 @@ class TiffOutputSummary implements TiffC
 
             for (int j = 0; j < imageDataInfo.outputItems.length; j++) {
                 final TiffOutputItem item = imageDataInfo.outputItems[j];
-                imageDataInfo.imageDataOffsets[j] = item.getOffset();
+                imageDataInfo.imageDataOffsets[j] = (int)item.getOffset();
             }
 
-            imageDataInfo.imageDataOffsetsField.setData(FIELD_TYPE_LONG
+            imageDataInfo.imageDataOffsetsField.setData(FieldType.LONG
                     .writeData(imageDataInfo.imageDataOffsets, byteOrder));
         }
     }

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/AsciiFieldTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/AsciiFieldTest.java?rev=1445822&r1=1445821&r2=1445822&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/AsciiFieldTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/AsciiFieldTest.java
Wed Feb 13 18:40:52 2013
@@ -56,7 +56,7 @@ public class AsciiFieldTest extends Exif
         // Good enough for our purposes, since the image in question is known.
         for (int i = 0; i < fields.size(); i++) {
             final TiffField field = fields.get(i);
-            fieldMap.put(field.tag, field);
+            fieldMap.put(field.getTag(), field);
         }
 
         final Map<Integer,Object> expectedFieldValues = new Hashtable<Integer,Object>();

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java?rev=1445822&r1=1445821&r2=1445822&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java
Wed Feb 13 18:40:52 2013
@@ -37,11 +37,10 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.common.bytesource.ByteSourceFile;
 import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata;
 import org.apache.commons.imaging.formats.jpeg.JpegUtils;
-import org.apache.commons.imaging.formats.jpeg.exif.ExifRewriter;
 import org.apache.commons.imaging.formats.tiff.TiffField;
 import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
 import org.apache.commons.imaging.formats.tiff.constants.AllTagConstants;
-import org.apache.commons.imaging.formats.tiff.constants.TiffFieldTypeConstants;
+import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType;
 import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet;
 import org.apache.commons.imaging.util.Debug;
 import org.apache.commons.imaging.util.IoUtils;
@@ -293,8 +292,8 @@ public class ExifRewriteTest extends Exi
         for (int i = 0; i < items.size(); i++) {
             final TiffImageMetadata.Item item = (TiffImageMetadata.Item) items.get(i);
             final TiffField field = item.getTiffField();
-            if (!fieldMap.containsKey(field.tag)) {
-                fieldMap.put(field.tag, field);
+            if (!fieldMap.containsKey(field.getTag())) {
+                fieldMap.put(field.getTag(), field);
             }
         }
         return fieldMap;
@@ -393,15 +392,15 @@ public class ExifRewriteTest extends Exi
                 assertNotNull(oldField);
                 assertNotNull(newField);
 
-                assertEquals(oldField.tag, newField.tag);
-                assertEquals(dirType.intValue(), newField.directoryType);
-                assertEquals(oldField.directoryType, newField.directoryType);
+                assertEquals(oldField.getTag(), newField.getTag());
+                assertEquals(dirType.intValue(), newField.getDirectoryType());
+                assertEquals(oldField.getDirectoryType(), newField.getDirectoryType());
 
-                if (oldField.fieldType == TiffFieldTypeConstants.FIELD_TYPE_ASCII) {
+                if (oldField.getFieldType() == FieldType.ASCII) {
                     // Imaging currently doesn't correctly rewrite
                     // strings if any byte had the highest bit set,
                     // so if the source had that, all bets are off.
-                    final byte[] rawBytes = oldField.fieldType.getRawBytes(oldField);
+                    final byte[] rawBytes = oldField.getByteArrayValue();
                     boolean hasInvalidByte = false;
                     for (final byte rawByte : rawBytes) {
                         if ((rawByte & 0x80) != 0) {
@@ -414,18 +413,18 @@ public class ExifRewriteTest extends Exi
                     }
                 }
 
-                assertEquals(oldField.length, newField.length);
+                assertEquals(oldField.getCount(), newField.getCount());
                 assertEquals(oldField.isLocalValue(), newField.isLocalValue());
 
-                if (oldField.tag == 0x202) {
+                if (oldField.getTag() == 0x202) {
                     // ignore "jpg from raw length" value. may have off-by-one
                     // bug in certain cameras.
                     // i.e. Sony DCR-PC110
                     continue;
                 }
 
-                if (!oldField.tagInfo.isOffset()) {
-                    if (oldField.tagInfo.isText()) { /* do nothing */
+                if (!oldField.getTagInfo().isOffset()) {
+                    if (oldField.getTagInfo().isText()) { /* do nothing */
                     } else if (oldField.isLocalValue()) {
                         // Debug.debug("oldField.tag", oldField.tag);
                         // Debug.debug("newField.tag", newField.tag);
@@ -448,11 +447,11 @@ public class ExifRewriteTest extends Exi
                         final String label = imageFile.getName() + ", dirType[" + i
                                 + "]=" + dirType + ", fieldTag[" + j + "]="
                                 + fieldTag;
-                        if (oldField.tag == 0x116 || oldField.tag == 0x117) {
+                        if (oldField.getTag() == 0x116 || oldField.getTag() == 0x117) {
                             compare(label, oldField, newField);
                         } else {
-                            compare(label, oldField.valueOffsetBytes,
-                                    newField.valueOffsetBytes,
+                            compare(label, oldField.getByteArrayValue(),
+                                    newField.getByteArrayValue(),
                                     oldField.getBytesLength(),
                                     newField.getBytesLength());
                         }
@@ -472,7 +471,7 @@ public class ExifRewriteTest extends Exi
                         // Debug.debug("newField.oversizeValue",
                         // newField.oversizeValue);
 
-                        compare(oldField.oversizeValue, newField.oversizeValue);
+                        compare(oldField.getByteArrayValue(), newField.getByteArrayValue());
                     }
                 }
 

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/MakerNoteFieldTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/MakerNoteFieldTest.java?rev=1445822&r1=1445821&r2=1445822&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/MakerNoteFieldTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/MakerNoteFieldTest.java
Wed Feb 13 18:40:52 2013
@@ -35,7 +35,7 @@ public class MakerNoteFieldTest extends 
     @Override
     protected void checkField(final File imageFile, final TiffField field)
             throws IOException, ImageReadException, ImageWriteException {
-        if (field.tag != ExifTagConstants.EXIF_TAG_MAKER_NOTE.tag) {
+        if (field.getTag() != ExifTagConstants.EXIF_TAG_MAKER_NOTE.tag) {
             // if (field.tag == EXIF_TAG_EXIF_OFFSET.tag)
             // ;
             // else
@@ -46,10 +46,10 @@ public class MakerNoteFieldTest extends 
         Debug.debug("field", field);
         Debug.debug("field", Debug.getType(field));
 
-        Debug.debug("field", field.tag);
-        Debug.debug("field", field.tagInfo);
-        Debug.debug("length", field.length);
-        Debug.debug("fieldType", field.fieldType);
+        Debug.debug("field", field.getTag());
+        Debug.debug("field", field.getTagInfo());
+        Debug.debug("length", field.getCount());
+        Debug.debug("fieldType", field.getFieldType());
         // Debug.debug("field", Debug.getType(field));
         Debug.debug();
 

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/TextFieldTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/TextFieldTest.java?rev=1445822&r1=1445821&r2=1445822&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/TextFieldTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/TextFieldTest.java
Wed Feb 13 18:40:52 2013
@@ -37,17 +37,17 @@ public class TextFieldTest extends Speci
     @Override
     protected void checkField(final File imageFile, final TiffField field)
             throws IOException, ImageReadException, ImageWriteException {
-        if (field.tag == ExifTagConstants.EXIF_TAG_USER_COMMENT.tag) { /*
+        if (field.getTag() == ExifTagConstants.EXIF_TAG_USER_COMMENT.tag) { /*
                                                                         * do
                                                                         * nothing
                                                                         */
-        } else if (field.tag == GpsTagConstants.GPS_TAG_GPS_PROCESSING_METHOD.tag
-                && field.directoryType == TiffDirectoryType.EXIF_DIRECTORY_GPS.directoryType)
{ /*
+        } else if (field.getTag() == GpsTagConstants.GPS_TAG_GPS_PROCESSING_METHOD.tag
+                && field.getDirectoryType() == TiffDirectoryType.EXIF_DIRECTORY_GPS.directoryType)
{ /*
                                                                                         
        * do
                                                                                         
        * nothing
                                                                                         
        */
-        } else if (field.tag == GpsTagConstants.GPS_TAG_GPS_AREA_INFORMATION.tag
-                && field.directoryType == TiffDirectoryType.EXIF_DIRECTORY_GPS.directoryType)
{ /*
+        } else if (field.getTag() == GpsTagConstants.GPS_TAG_GPS_AREA_INFORMATION.tag
+                && field.getDirectoryType() == TiffDirectoryType.EXIF_DIRECTORY_GPS.directoryType)
{ /*
                                                                                         
        * do
                                                                                         
        * nothing
                                                                                         
        */



Mime
View raw message