commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1307748 - in /commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff: constants/ taginfos/ write/
Date Sat, 31 Mar 2012 09:31:37 GMT
Author: damjan
Date: Sat Mar 31 09:31:37 2012
New Revision: 1307748

URL: http://svn.apache.org/viewvc?rev=1307748&view=rev
Log:
Add some new TagInfo types.


Added:
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/taginfos/TagInfoAsciiOrByte.java
  (with props)
Modified:
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/DngTagConstants.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/ExifTagConstants.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/TiffFieldTypeConstants.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/taginfos/TagInfoAsciiOrRational.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputDirectory.java

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/DngTagConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/DngTagConstants.java?rev=1307748&r1=1307747&r2=1307748&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/DngTagConstants.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/DngTagConstants.java
Sat Mar 31 09:31:37 2012
@@ -6,6 +6,7 @@ import java.util.List;
 
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfo;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoAscii;
+import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoAsciiOrByte;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoByte;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoDouble;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoFloat;
@@ -36,8 +37,7 @@ public interface DngTagConstants extends
             "Unique Camera Model", 0xc614, -1,
             TiffDirectoryType.EXIF_DIRECTORY_IFD0);
 
-    // FIXME: byte or ascii
-    public static final TagInfoAscii EXIF_TAG_LOCALIZED_CAMERA_MODEL = new TagInfoAscii(
+    public static final TagInfoAsciiOrByte EXIF_TAG_LOCALIZED_CAMERA_MODEL = new TagInfoAsciiOrByte(
             "Localized Camera Model", 0xc615, -1,
             TiffDirectoryType.EXIF_DIRECTORY_IFD0);
 
@@ -236,8 +236,7 @@ public interface DngTagConstants extends
             "Raw Data Unique ID", 0xc65d, 16,
             TiffDirectoryType.EXIF_DIRECTORY_IFD0);
 
-    // FIXME: byte or ascii
-    public static final TagInfoAscii EXIF_TAG_ORIGINAL_RAW_FILE_NAME = new TagInfoAscii(
+    public static final TagInfoAsciiOrByte EXIF_TAG_ORIGINAL_RAW_FILE_NAME = new TagInfoAsciiOrByte(
             "Original Raw File Name", 0xc68b, -1,
             TiffDirectoryType.EXIF_DIRECTORY_IFD0);
 
@@ -275,13 +274,11 @@ public interface DngTagConstants extends
     public static final short COLORIMETRIC_REFERENCE_VALUE_SCENE_REFERRED = 0;
     public static final short COLORIMETRIC_REFERENCE_VALUE_OUTPUT_REFERRED = 1;
     
-    // FIXME: ascii or byte
-    public static final TagInfoAscii EXIF_TAG_CAMERA_CALIBRATION_SIGNATURE = new TagInfoAscii(
+    public static final TagInfoAsciiOrByte EXIF_TAG_CAMERA_CALIBRATION_SIGNATURE = new TagInfoAsciiOrByte(
             "Camera Calibration Signature", 0xc6f3, -1,
             TiffDirectoryType.EXIF_DIRECTORY_IFD0);
     
-    // FIXME: ascii or byte
-    public static final TagInfoAscii EXIF_TAG_PROFILE_CALIBRATION_SIGNATURE = new TagInfoAscii(
+    public static final TagInfoAsciiOrByte EXIF_TAG_PROFILE_CALIBRATION_SIGNATURE = new TagInfoAsciiOrByte(
             "Profile Calibration Signature", 0xc6f4, -1,
             TiffDirectoryType.EXIF_DIRECTORY_IFD0);
     
@@ -289,8 +286,7 @@ public interface DngTagConstants extends
             "Extra Camera Profiles", 0xc6f5, -1,
             TiffDirectoryType.EXIF_DIRECTORY_IFD0);
     
-    // FIXME: ascii or byte
-    public static final TagInfoAscii EXIF_TAG_AS_SHOT_PROFILE_NAME = new TagInfoAscii(
+    public static final TagInfoAsciiOrByte EXIF_TAG_AS_SHOT_PROFILE_NAME = new TagInfoAsciiOrByte(
             "As Shot Profile Name", 0xc6f6, -1,
             TiffDirectoryType.EXIF_DIRECTORY_IFD0);
     
@@ -326,8 +322,7 @@ public interface DngTagConstants extends
     public static final int PROFILE_EMBED_POLICY_VALUE_EMBED_NEVER = 2;
     public static final int PROFILE_EMBED_POLICY_VALUE_NO_RESTRICTIONS = 3;
     
-    // FIXME: ascii or byte
-    public static final TagInfoAscii EXIF_TAG_PROFILE_COPYRIGHT = new TagInfoAscii(
+    public static final TagInfoAsciiOrByte EXIF_TAG_PROFILE_COPYRIGHT = new TagInfoAsciiOrByte(
             "Profile Copyright", 0xc6fe, -1,
             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
     
@@ -339,18 +334,15 @@ public interface DngTagConstants extends
             "Forward Matrix 2", 0xc715, -1,
             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
     
-    // FIXME: ascii or byte
-    public static final TagInfoAscii EXIF_TAG_PREVIEW_APPLICATION_NAME = new TagInfoAscii(
+    public static final TagInfoAsciiOrByte EXIF_TAG_PREVIEW_APPLICATION_NAME = new TagInfoAsciiOrByte(
             "Preview Application Name", 0xc716, -1,
             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
     
-    // FIXME: ascii or byte
-    public static final TagInfoAscii EXIF_TAG_PREVIEW_APPLICATION_VERSION = new TagInfoAscii(
+    public static final TagInfoAsciiOrByte EXIF_TAG_PREVIEW_APPLICATION_VERSION = new TagInfoAsciiOrByte(
             "Preview Application Version", 0xc717, -1,
             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
 
-    // FIXME: ascii or byte
-    public static final TagInfoAscii EXIF_TAG_PREVIEW_SETTINGS_NAME = new TagInfoAscii(
+    public static final TagInfoAsciiOrByte EXIF_TAG_PREVIEW_SETTINGS_NAME = new TagInfoAsciiOrByte(
             "Preview Settings Name", 0xc718, -1,
             TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN);
 

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/ExifTagConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/ExifTagConstants.java?rev=1307748&r1=1307747&r2=1307748&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/ExifTagConstants.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/ExifTagConstants.java
Sat Mar 31 09:31:37 2012
@@ -21,25 +21,18 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfo;
-import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoAny;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoAscii;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoByte;
-import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoByteOrShort;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoDouble;
-import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoFloat;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoGpsText;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoLong;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoRational;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoSLong;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoSRational;
-import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoSShort;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoShort;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoShortOrLong;
-import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoShortOrLongOrRational;
-import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoShortOrRational;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoUndefined;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoUnknown;
-import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoXpString;
 
 /**
  * References:

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/TiffFieldTypeConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/TiffFieldTypeConstants.java?rev=1307748&r1=1307747&r2=1307748&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/TiffFieldTypeConstants.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/constants/TiffFieldTypeConstants.java
Sat Mar 31 09:31:37 2012
@@ -100,4 +100,8 @@ public interface TiffFieldTypeConstants 
     public static final List<FieldType> FIELD_TYPE_DESCRIPTION_ASCII_OR_RATIONAL =
             Collections.unmodifiableList(Arrays.asList(
                     FIELD_TYPE_ASCII, FIELD_TYPE_RATIONAL));
+    
+    public static final List<FieldType> FIELD_TYPE_DESCRIPTION_ASCII_OR_BYTE =
+            Collections.unmodifiableList(Arrays.asList(
+                    FIELD_TYPE_ASCII, FIELD_TYPE_BYTE));
 }
\ No newline at end of file

Added: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/taginfos/TagInfoAsciiOrByte.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/taginfos/TagInfoAsciiOrByte.java?rev=1307748&view=auto
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/taginfos/TagInfoAsciiOrByte.java
(added)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/taginfos/TagInfoAsciiOrByte.java
Sat Mar 31 09:31:37 2012
@@ -0,0 +1,9 @@
+package org.apache.commons.sanselan.formats.tiff.taginfos;
+
+import org.apache.commons.sanselan.formats.tiff.constants.TiffDirectoryType;
+
+public class TagInfoAsciiOrByte extends TagInfo {
+    public TagInfoAsciiOrByte(String name, int tag, int length, TiffDirectoryType directoryType)
{
+        super(name, tag, FIELD_TYPE_DESCRIPTION_ASCII_OR_BYTE, length, directoryType, false);
+    }
+}

Propchange: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/taginfos/TagInfoAsciiOrByte.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/taginfos/TagInfoAsciiOrRational.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/taginfos/TagInfoAsciiOrRational.java?rev=1307748&r1=1307747&r2=1307748&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/taginfos/TagInfoAsciiOrRational.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/taginfos/TagInfoAsciiOrRational.java
Sat Mar 31 09:31:37 2012
@@ -4,6 +4,6 @@ import org.apache.commons.sanselan.forma
 
 public class TagInfoAsciiOrRational extends TagInfo {
     public TagInfoAsciiOrRational(String name, int tag, int length, TiffDirectoryType directoryType)
{
-        super(name, tag, FIELD_TYPE_DESCRIPTION_SHORT_OR_RATIONAL, length, directoryType,
false);
+        super(name, tag, FIELD_TYPE_DESCRIPTION_ASCII_OR_RATIONAL, length, directoryType,
false);
     }
 }

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputDirectory.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputDirectory.java?rev=1307748&r1=1307747&r2=1307748&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputDirectory.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputDirectory.java
Sat Mar 31 09:31:37 2012
@@ -37,6 +37,8 @@ import org.apache.commons.sanselan.forma
 import org.apache.commons.sanselan.formats.tiff.fieldtypes.FieldType;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfo;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoAscii;
+import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoAsciiOrByte;
+import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoAsciiOrRational;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoByte;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoByteOrShort;
 import org.apache.commons.sanselan.formats.tiff.taginfos.TagInfoDouble;
@@ -98,8 +100,8 @@ public final class TiffOutputDirectory e
     public void add(TagInfoAscii tagInfo, String... values) throws ImageWriteException {
         byte[] bytes = tagInfo.encodeValue(byteOrder, values);
         if (tagInfo.length > 0 && tagInfo.length != bytes.length) {
-            //throw new ImageWriteException("Tag expects " + tagInfo.length +
-              //      " byte(s), not " + values.length);
+            throw new ImageWriteException("Tag expects " + tagInfo.length +
+                    " byte(s), not " + values.length);
         }
         TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag, tagInfo,
                 TiffFieldTypeConstants.FIELD_TYPE_ASCII, bytes.length, bytes);
@@ -318,6 +320,39 @@ public final class TiffOutputDirectory e
         add(tiffOutputField);
     }
     
+    public void add(TagInfoAsciiOrByte tagInfo, String... values) throws ImageWriteException
{
+        byte[] bytes = tagInfo.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII, values,
byteOrder);
+        if (tagInfo.length > 0 && tagInfo.length != bytes.length) {
+            throw new ImageWriteException("Tag expects " + tagInfo.length +
+                    " byte(s), not " + values.length);
+        }
+        TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag, tagInfo,
+                TiffFieldTypeConstants.FIELD_TYPE_ASCII, bytes.length, bytes);
+        add(tiffOutputField);
+    }
+    
+    public void add(TagInfoAsciiOrRational tagInfo, String... values) throws ImageWriteException
{
+        byte[] bytes = tagInfo.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII, values,
byteOrder);
+        if (tagInfo.length > 0 && tagInfo.length != bytes.length) {
+            throw new ImageWriteException("Tag expects " + tagInfo.length +
+                    " byte(s), not " + values.length);
+        }
+        TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag, tagInfo,
+                TiffFieldTypeConstants.FIELD_TYPE_ASCII, bytes.length, bytes);
+        add(tiffOutputField);
+    }
+    
+    public void add(TagInfoAsciiOrRational tagInfo, RationalNumber... values) throws ImageWriteException
{
+        if (tagInfo.length > 0 && tagInfo.length != values.length) {
+            throw new ImageWriteException("Tag expects " + tagInfo.length +
+                    " value(s), not " + values.length);
+        }
+        byte[] bytes = tagInfo.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_RATIONAL, values,
byteOrder);
+        TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag, tagInfo,
+                TiffFieldTypeConstants.FIELD_TYPE_RATIONAL, bytes.length, bytes);
+        add(tiffOutputField);
+    }
+    
     public void add(TiffOutputField field)
     {
         fields.add(field);



Mime
View raw message