commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1212318 - /commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/write/TiffOutputField.java
Date Fri, 09 Dec 2011 10:18:21 GMT
Author: damjan
Date: Fri Dec  9 10:18:21 2011
New Revision: 1212318

URL: http://svn.apache.org/viewvc?rev=1212318&view=rev
Log:
Detect ASCII field types more rigorously,
and write their correct length when writing
TIFF tags.

This is based on bits from SANSELAN-51
and SANSELAN-12, however neither of those
is complete or correct by itself or even
when they're put together.

This resolves SANSELAN-12 and fixes part 1
of SANSELAN-51.

Jira issue keys: SANSELAN-12 , SANSELAN-51


Modified:
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/write/TiffOutputField.java

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/write/TiffOutputField.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/write/TiffOutputField.java?rev=1212318&r1=1212317&r2=1212318&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/write/TiffOutputField.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/write/TiffOutputField.java
Fri Dec  9 10:18:21 2011
@@ -97,16 +97,19 @@ public class TiffOutputField implements 
             String value) throws ImageWriteException
     {
         FieldType fieldType;
-        if (tagInfo.dataTypes == null)
-            fieldType = FIELD_TYPE_ASCII;
-        else if (tagInfo.dataTypes == FIELD_TYPE_DESCRIPTION_ASCII)
+        if (tagInfo.dataTypes == null || tagInfo.dataTypes.length < 1)
             fieldType = FIELD_TYPE_ASCII;
         else
-            throw new ImageWriteException("Tag has unexpected data type.");
+        {
+            if (tagInfo.dataTypes[0] == FIELD_TYPE_ASCII)
+                fieldType = FIELD_TYPE_ASCII;
+            else
+                throw new ImageWriteException("Tag has unexpected data type.");
+        }
 
         byte bytes[] = fieldType.writeData(value, byteOrder);
 
-        return new TiffOutputField(tagInfo.tag, tagInfo, fieldType, 1, bytes);
+        return new TiffOutputField(tagInfo.tag, tagInfo, fieldType, bytes.length, bytes);
     }
 
     protected static final TiffOutputField createOffsetField(TagInfo tagInfo,



Mime
View raw message