commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1416148 - in /commons/proper/imaging/trunk/src: main/java/org/apache/commons/imaging/formats/png/ main/java/org/apache/commons/imaging/formats/png/transparencyfilters/ main/java/org/apache/commons/imaging/formats/tiff/ main/java/org/apache...
Date Sun, 02 Dec 2012 09:57:50 GMT
Author: damjan
Date: Sun Dec  2 09:57:49 2012
New Revision: 1416148

URL: http://svn.apache.org/viewvc?rev=1416148&view=rev
Log:
When not in strict mode, allow errors when reading
subdirectory tags (and ignore the tags in that case).

Jira issue key: IMAGING-90


Added:
    commons/proper/imaging/trunk/src/test/data/images/tiff/6/
    commons/proper/imaging/trunk/src/test/data/images/tiff/6/bad-interoperability.asm
    commons/proper/imaging/trunk/src/test/data/images/tiff/6/bad-interoperability.tiff   (with
props)
Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngConstants.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColor.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngConstants.java?rev=1416148&r1=1416147&r2=1416148&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngConstants.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngConstants.java
Sun Dec  2 09:57:49 2012
@@ -28,6 +28,8 @@ public interface PngConstants extends Im
             new byte[] { 73, 72, 68, 82 });
     public final static BinaryConstant PLTE_CHUNK_TYPE = new BinaryConstant(
             new byte[] { 80, 76, 84, 69 });
+    public final static BinaryConstant TRNS_CHUNK_TYPE = new BinaryConstant(
+            new byte[] { 't', 'R', 'N', 'S'});
     public final static BinaryConstant IEND_CHUNK_TYPE = new BinaryConstant(
             new byte[] { 73, 69, 78, 68 });
     public final static BinaryConstant IDAT_CHUNK_TYPE = new BinaryConstant(

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java?rev=1416148&r1=1416147&r2=1416148&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java
Sun Dec  2 09:57:49 2012
@@ -48,22 +48,20 @@ public class PngWriter implements PngCon
     }
 
     /*
-     * 1. IHDR: image header, which is the first chunk in a PNG datastream. 2.
-     * PLTE: palette table associated with indexed PNG images. 3. IDAT: image
-     * data chunks. 4. IEND: image trailer, which is the last chunk in a PNG
-     * datastream.
-     * 
-     * The remaining 14 chunk types are termed ancillary chunk types, which
-     * encoders may generate and decoders may interpret.
-     * 
-     * 1. Transparency information: tRNS (see 11.3.2: Transparency information).
-     * 2. Colour space information: cHRM, gAMA, iCCP, sBIT, sRGB (see 11.3.3:
-     * Colour space information). 3. Textual information: iTXt, tEXt, zTXt (see
-     * 11.3.4: Textual information). 4. Miscellaneous information: bKGD, hIST,
-     * pHYs, sPLT (see 11.3.5: Miscellaneous information). 5. Time information:
-     * tIME (see 11.3.6: Time stamp information).
-     */
-
+     1. IHDR: image header, which is the first chunk in a PNG datastream.
+     2. PLTE: palette table associated with indexed PNG images.
+     3. IDAT: image data chunks.
+     4. IEND: image trailer, which is the last chunk in a PNG datastream.
+
+     The remaining 14 chunk types are termed ancillary chunk types, which encoders may generate
and decoders may interpret.
+
+     1. Transparency information: tRNS (see 11.3.2: Transparency information).
+     2. Colour space information: cHRM, gAMA, iCCP, sBIT, sRGB (see 11.3.3: Colour space
information).
+     3. Textual information: iTXt, tEXt, zTXt (see 11.3.4: Textual information).
+     4. Miscellaneous information: bKGD, hIST, pHYs, sPLT (see 11.3.5: Miscellaneous information).
+     5. Time information: tIME (see 11.3.6: Time stamp information).
+    */
+    
     private final void writeInt(OutputStream os, int value) throws IOException {
         os.write(0xff & (value >> 24));
         os.write(0xff & (value >> 16));
@@ -80,26 +78,14 @@ public class PngWriter implements PngCon
             os.write(data);
         }
 
-        // Debug.debug("writeChunk chunkType", chunkType);
-        // Debug.debug("writeChunk data", data);
-
-        {
-            PngCrc png_crc = new PngCrc();
+        PngCrc png_crc = new PngCrc();
 
-            long crc1 = png_crc.start_partial_crc(chunkType, chunkType.length);
-            long crc2 = data == null ? crc1 : png_crc.continue_partial_crc(
-                    crc1, data, data.length);
-            int crc = (int) png_crc.finish_partial_crc(crc2);
-
-            // Debug.debug("crc1", crc1 + " (" + Long.toHexString(crc1)
-            // + ")");
-            // Debug.debug("crc2", crc2 + " (" + Long.toHexString(crc2)
-            // + ")");
-            // Debug.debug("crc3", crc + " (" + Integer.toHexString(crc)
-            // + ")");
+        long crc1 = png_crc.start_partial_crc(chunkType, chunkType.length);
+        long crc2 = data == null ? crc1 : png_crc.continue_partial_crc(
+                crc1, data, data.length);
+        int crc = (int) png_crc.finish_partial_crc(crc2);
 
-            writeInt(os, crc);
-        }
+        writeInt(os, crc);
     }
 
     private static class ImageHeader {
@@ -264,6 +250,16 @@ public class PngWriter implements PngCon
 
         writeChunk(os, PLTE_CHUNK_TYPE.toByteArray(), bytes);
     }
+    
+    private void writeChunkTRNS(OutputStream os, Palette palette) throws IOException {
+        byte[] bytes = new byte[palette.length()];
+        
+        for (int i = 0; i < bytes.length; i++) {
+            bytes[i] = (byte) (0xff & (palette.getEntry(i) >> 24));
+        }
+        
+        writeChunk(os, TRNS_CHUNK_TYPE.toByteArray(), bytes);
+    }
 
     private void writeChunkIEND(OutputStream os) throws IOException {
         writeChunk(os, IEND_CHUNK_TYPE.toByteArray(), null);
@@ -348,21 +344,33 @@ public class PngWriter implements PngCon
     }
 
     /*
-     * between two chunk types indicates alternatives. Table 5.3 — Chunk
-     * ordering rules Critical chunks (shall appear in this order, except PLTE
-     * is optional) Chunk name Multiple allowed Ordering constraints IHDR No
-     * Shall be first PLTE No Before first IDAT IDAT Yes Multiple IDAT chunks
-     * shall be consecutive IEND No Shall be last Ancillary chunks (need not
-     * appear in this order) Chunk name Multiple allowed Ordering constraints
-     * cHRM No Before PLTE and IDAT gAMA No Before PLTE and IDAT iCCP No Before
-     * PLTE and IDAT. If the iCCP chunk is present, the sRGB chunk should not be
-     * present. sBIT No Before PLTE and IDAT sRGB No Before PLTE and IDAT. If
-     * the sRGB chunk is present, the iCCP chunk should not be present. bKGD No
-     * After PLTE; before IDAT hIST No After PLTE; before IDAT tRNS No After
-     * PLTE; before IDAT pHYs No Before IDAT sPLT Yes Before IDAT tIME No None
-     * iTXt Yes None tEXt Yes None zTXt Yes None
-     */
-
+     between two chunk types indicates alternatives.
+     Table 5.3 — Chunk ordering rules Critical chunks
+     (shall appear in this order, except PLTE is optional)
+     Chunk name     Multiple allowed    Ordering constraints
+     IHDR   No  Shall be first
+     PLTE   No  Before first IDAT
+     IDAT   Yes     Multiple IDAT chunks shall be consecutive
+     IEND   No  Shall be last
+     Ancillary chunks
+     (need not appear in this order)
+     Chunk name     Multiple allowed    Ordering constraints
+     cHRM   No  Before PLTE and IDAT
+     gAMA   No  Before PLTE and IDAT
+     iCCP   No  Before PLTE and IDAT. If the iCCP chunk is present, the sRGB chunk should
not be present.
+     sBIT   No  Before PLTE and IDAT
+     sRGB   No  Before PLTE and IDAT. If the sRGB chunk is present, the iCCP chunk should
not be present.
+     bKGD   No  After PLTE; before IDAT
+     hIST   No  After PLTE; before IDAT
+     tRNS   No  After PLTE; before IDAT
+     pHYs   No  Before IDAT
+     sPLT   Yes     Before IDAT
+     tIME   No  None
+     iTXt   Yes     None
+     tEXt   Yes     None
+     zTXt   Yes     None
+    */
+    
     public void writeImage(BufferedImage src, OutputStream os, Map<String,Object> params)
             throws ImageWriteException, IOException {
         // make copy of params; we'll clear keys as we consume them.
@@ -480,29 +488,25 @@ public class PngWriter implements PngCon
         if (colorType == COLOR_TYPE_INDEXED_COLOR) {
             // PLTE No Before first IDAT
 
-            int max_colors = hasAlpha ? 255 : 256;
-
-            palette = new MedianCutQuantizer(true).process(src, max_colors,
+            palette = new MedianCutQuantizer(!hasAlpha).process(src, 256,
                     verbose);
-            // Palette palette2 = new PaletteFactory().makePaletteSimple(src,
-            // max_colors);
-
-            // palette.dump();
-
             writeChunkPLTE(os, palette);
+            if (hasAlpha) {
+                writeChunkTRNS(os, palette);
+            }
         }
 
         Object pixelDensityObj = params.get(PARAM_KEY_PIXEL_DENSITY);
         if (pixelDensityObj instanceof PixelDensity) {
             PixelDensity pixelDensity = (PixelDensity) pixelDensityObj;
             if (pixelDensity.isUnitless()) {
-                writeChunkPHYS(os, (int) Math.round(pixelDensity
-                        .getRawHorizontalDensity()),
+                writeChunkPHYS(os,
+                        (int) Math.round(pixelDensity.getRawHorizontalDensity()),
                         (int) Math.round(pixelDensity.getRawVerticalDensity()),
                         (byte) 0);
             } else {
-                writeChunkPHYS(os, (int) Math.round(pixelDensity
-                        .horizontalDensityMetres()),
+                writeChunkPHYS(os,
+                        (int) Math.round(pixelDensity.horizontalDensityMetres()),
                         (int) Math.round(pixelDensity.verticalDensityMetres()),
                         (byte) 1);
             }
@@ -628,16 +632,24 @@ public class PngWriter implements PngCon
         }
 
         /*
-         * Ancillary chunks (need not appear in this order) Chunk name Multiple
-         * allowed Ordering constraints cHRM No Before PLTE and IDAT gAMA No
-         * Before PLTE and IDAT iCCP No Before PLTE and IDAT. If the iCCP chunk
-         * is present, the sRGB chunk should not be present. sBIT No Before PLTE
-         * and IDAT sRGB No Before PLTE and IDAT. If the sRGB chunk is present,
-         * the iCCP chunk should not be present. bKGD No After PLTE; before IDAT
-         * hIST No After PLTE; before IDAT tRNS No After PLTE; before IDAT pHYs
-         * No Before IDAT sPLT Yes Before IDAT tIME No None iTXt Yes None tEXt
-         * Yes None zTXt Yes None
-         */
+         Ancillary chunks
+         (need not appear in this order)
+         Chunk name     Multiple allowed    Ordering constraints
+         cHRM           No                  Before PLTE and IDAT
+         gAMA           No                  Before PLTE and IDAT
+         iCCP           No                  Before PLTE and IDAT. If the iCCP chunk is present,
the sRGB chunk should not be present.
+         sBIT           No                  Before PLTE and IDAT
+         sRGB           No                  Before PLTE and IDAT. If the sRGB chunk is present,
the iCCP chunk should not be present.
+         bKGD           No                  After PLTE; before IDAT
+         hIST           No                  After PLTE; before IDAT
+         tRNS           No                  After PLTE; before IDAT
+         pHYs           No                  Before IDAT
+         sPLT           Yes                 Before IDAT
+         tIME           No                  None
+         iTXt           Yes                 None
+         tEXt           Yes                 None
+         zTXt           Yes                 None
+        */
 
         os.close();
     } // todo: filter types

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColor.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColor.java?rev=1416148&r1=1416147&r2=1416148&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColor.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/transparencyfilters/TransparencyFilterIndexedColor.java
Sun Dec  2 09:57:49 2012
@@ -26,27 +26,19 @@ public class TransparencyFilterIndexedCo
         super(bytes);
     }
 
-    int count = 0;
-
     @Override
     public int filter(int rgb, int index) throws ImageReadException,
             IOException {
         if (index >= bytes.length) {
             return rgb;
-        }
-
-        if ((index < 0) || (index > bytes.length)) {
+        } else if (index < 0) {
             throw new ImageReadException(
-                    "TransparencyFilterIndexedColor index: " + index
-                            + ", bytes.length: " + bytes.length);
+                    "Invalid TransparencyFilterIndexedColor index: " + index);
         }
 
         int alpha = bytes[index];
         int result = ((0xff & alpha) << 24) | (0x00ffffff & rgb);
 
-        if ((count < 100) && (index > 0)) {
-            count++;
-        }
         return result;
     }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java?rev=1416148&r1=1416147&r2=1416148&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
Sun Dec  2 09:57:49 2012
@@ -32,6 +32,7 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants;
 import org.apache.commons.imaging.formats.tiff.constants.TiffConstants;
 import org.apache.commons.imaging.formats.tiff.constants.TiffTagConstants;
+import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoLong;
 import org.apache.commons.imaging.util.Debug;
 
 public class TiffReader extends BinaryFileParser implements TiffConstants {
@@ -245,48 +246,39 @@ public class TiffReader extends BinaryFi
             }
 
             if (listener.readOffsetDirectories()) {
-                List<TiffField> fieldsToRemove = new ArrayList<TiffField>();
-                for (int j = 0; j < fields.size(); j++) {
-                    TiffField entry = fields.get(j);
-
-                    if (entry.tag == ExifTagConstants.EXIF_TAG_EXIF_OFFSET.tag
-                            || entry.tag == ExifTagConstants.EXIF_TAG_GPSINFO.tag
-                            || entry.tag == ExifTagConstants.EXIF_TAG_INTEROP_OFFSET.tag)
{ /*
-                                                                                        
    * do
-                                                                                        
    * nothing
-                                                                                        
    */
-                    } else {
-                        continue;
-                    }
-
-                    int subDirectoryOffset = ((Number) entry.getValue())
-                            .intValue();
-                    int subDirectoryType;
-                    if (entry.tag == ExifTagConstants.EXIF_TAG_EXIF_OFFSET.tag) {
-                        subDirectoryType = TiffDirectory.DIRECTORY_TYPE_EXIF;
-                    } else if (entry.tag == ExifTagConstants.EXIF_TAG_GPSINFO.tag) {
-                        subDirectoryType = TiffDirectory.DIRECTORY_TYPE_GPS;
-                    } else if (entry.tag == ExifTagConstants.EXIF_TAG_INTEROP_OFFSET.tag)
{
-                        subDirectoryType = TiffDirectory.DIRECTORY_TYPE_INTEROPERABILITY;
-                    } else {
-                        throw new ImageReadException(
-                                "Unknown subdirectory type.");
-                    }
-
-                    // Debug.debug("sub dir", subDirectoryOffset);
-                    boolean subDirectoryRead = readDirectory(byteSource,
-                            subDirectoryOffset, subDirectoryType,
-                            formatCompliance, listener, true, visited);
-
-                    if (!subDirectoryRead) {
-                        // Offset field pointed to invalid location.
-                        // This is a bug in certain cameras. Ignore offset
-                        // field.
-                        fieldsToRemove.add(entry);
+                final TagInfoLong[] offsetFields = {
+                        EXIF_TAG_EXIF_OFFSET,
+                        EXIF_TAG_GPSINFO,
+                        EXIF_TAG_INTEROP_OFFSET
+                };
+                final int[] directoryTypes = {
+                        TiffDirectory.DIRECTORY_TYPE_EXIF,
+                        TiffDirectory.DIRECTORY_TYPE_GPS,
+                        TiffDirectory.DIRECTORY_TYPE_INTEROPERABILITY
+                };
+                for (int i = 0; i < offsetFields.length; i++) {
+                    TagInfoLong offsetField = offsetFields[i];
+                    if (directory.findField(offsetField) != null) {
+                        int subDirectoryOffset;
+                        int subDirectoryType;
+                        boolean subDirectoryRead = false;
+                        try {
+                            subDirectoryOffset = directory.getSingleFieldValue(offsetField);
+                            subDirectoryType = directoryTypes[i];
+                            subDirectoryRead = readDirectory(byteSource,
+                                    subDirectoryOffset, subDirectoryType,
+                                    formatCompliance, listener, true, visited);
+    
+                        } catch (ImageReadException imageReadException) {
+                            if (strict) {
+                                throw imageReadException;
+                            }
+                        }
+                        if (!subDirectoryRead) {
+                            fields.remove(offsetField);
+                        }
                     }
-
                 }
-                fields.removeAll(fieldsToRemove);
             }
 
             if (!ignoreNextDirectory && directory.nextDirectoryOffset > 0) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java?rev=1416148&r1=1416147&r2=1416148&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java
Sun Dec  2 09:57:49 2012
@@ -21,8 +21,10 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.commons.imaging.ImageWriteException;
 import org.apache.commons.imaging.util.Debug;
@@ -89,6 +91,7 @@ public class MedianCutQuantizer {
 
         public final int max_diff;
         public final int diff_total;
+        public final int totalPoints;
 
         public ColorGroup(final List<ColorCount> color_counts)
                 throws ImageWriteException {
@@ -98,8 +101,10 @@ public class MedianCutQuantizer {
                 throw new ImageWriteException("empty color_group");
             }
 
+            int totalPoints = 0;
             for (int i = 0; i < color_counts.size(); i++) {
                 ColorCount color = color_counts.get(i);
+                totalPoints += color.count;
 
                 min_alpha = Math.min(min_alpha, color.alpha);
                 max_alpha = Math.max(max_alpha, color.alpha);
@@ -110,6 +115,7 @@ public class MedianCutQuantizer {
                 min_blue = Math.min(min_blue, color.blue);
                 max_blue = Math.max(max_blue, color.blue);
             }
+            this.totalPoints = totalPoints;
 
             alpha_diff = max_alpha - min_alpha;
             red_diff = max_red - min_red;
@@ -271,21 +277,37 @@ public class MedianCutQuantizer {
 
         final Comparator<ColorGroup> comparator = new Comparator<ColorGroup>()
{
             public int compare(ColorGroup cg1, ColorGroup cg2) {
-                if (cg1.max_diff == cg2.max_diff) {
-                    return cg2.diff_total - cg1.diff_total;
-                }
-                return cg2.max_diff - cg1.max_diff;
+                return cg2.totalPoints - cg1.totalPoints;
+//                if (cg1.max_diff == cg2.max_diff) {
+//                    return cg2.diff_total - cg1.diff_total;
+//                }
+//                return cg2.max_diff - cg1.max_diff;
             }
         };
 
+        Set<ColorGroup> ignore = new HashSet<ColorGroup>();
         while (color_groups.size() < max_colors) {
             Collections.sort(color_groups, comparator);
 
             ColorGroup color_group = color_groups.get(0);
-
-            if (color_group.max_diff == 0) {
-                break;
-            }
+//            if (color_group.max_diff == 0) {
+//                for (ColorGroup c : color_groups) {
+//                    System.out.println("max_diff: " + c.max_diff);
+//                }
+//                break;
+//            }
+            
+//            ColorGroup color_group = null;
+//            for (ColorGroup c : color_groups) {
+//                if (c.max_diff > 0) {
+//                    color_group = c;
+//                    break;
+//                }
+//            }
+//            if (color_group == null) {
+//                break;
+//            }
+            
             if (!ignoreAlpha
                     && color_group.alpha_diff > color_group.red_diff
                     && color_group.alpha_diff > color_group.green_diff

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java?rev=1416148&r1=1416147&r2=1416148&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java
Sun Dec  2 09:57:49 2012
@@ -334,7 +334,7 @@ public class PaletteFactory {
      * Builds an inexact opaque palette of at most {@code max} colors in {@code src}
      * using a variation of the Median Cut algorithm. Accurate to 6 bits per component,
      * and works by splitting the color bounding box most heavily populated by colors
-     * along the component which splits the colors most evenly.
+     * along the component which splits the colors in that box most evenly.
      * @param src the image whose palette to build
      * @param max the maximum number of colors the palette can contain
      * @return the palette of at most {@code max} colors

Added: commons/proper/imaging/trunk/src/test/data/images/tiff/6/bad-interoperability.asm
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/data/images/tiff/6/bad-interoperability.asm?rev=1416148&view=auto
==============================================================================
--- commons/proper/imaging/trunk/src/test/data/images/tiff/6/bad-interoperability.asm (added)
+++ commons/proper/imaging/trunk/src/test/data/images/tiff/6/bad-interoperability.asm Sun
Dec  2 09:57:49 2012
@@ -0,0 +1,115 @@
+; 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.
+
+
+; Assemblers are the perfect tool for generating
+; custom test images as they let us insert offsets
+; to unknown locations easily and totally
+; customize the file byte-by-byte.
+;
+; To generate a TIFF from this, run:
+; nasm -f bin /path/to/this/file.asm -o /path/to/file.tiff
+
+; TIFF header
+db 0x49,0x49
+db 0x2a, 0x00
+db 0x08, 0x00, 0x00, 0x00
+
+; Number of directory entries
+dw 8
+
+; entry 0: tag, type, count, value
+dw 0x0100 ; tag = image width
+dw 3 ; type = short
+dd 1 ; length = 1
+dd 2 ; value = 2
+
+; entry 1
+dw 0x0101 ; tag = image length
+dw 3 ; type = short
+dd 1 ; length = 1
+dd 2 ; value = 2
+
+; entry 2
+dw 0x0103 ; tag = compression
+dw 3
+dd 1
+dd 1 ; no compression, but pack bits tightly
+
+; entry 3
+dw 0x0106 ; tag = PhotometricInterpretation
+dw 3
+dd 1
+dd 1 ; black is zero
+
+; entry 4
+dw 0x0111 ; tag = StripOffsets
+dw 4 ; type = long
+dd 1
+dd $imageStrip1
+
+; entry 5
+dw 0x0117 ; tag = StripByteCounts
+dw 4 ; type = long
+dd 1
+dd 2
+
+; entry 6
+dw 0x0116 ; tag = RowsPerStrip
+dw 4 ; type = long
+dd 1
+dd 2
+
+; entry 7
+dw 0x8769 ; tag = EXIF
+dw 4 ; type = long
+dd 1
+dd $exif
+
+; offset to next directory
+dd 0
+
+
+; values that couldn't fit:
+
+
+; image data
+imageStrip1:
+db 0x80, 0x40
+
+
+; EXIF
+
+exif:
+; number of directory entries:
+dw 1
+
+; entry 0
+dw 0xA005 ; tag = Interoperability
+dw  4 ; type = long
+dd 0 ; bad count of 0
+dd $interoperability
+
+; offset to next directory
+dd 0
+
+interoperability:
+; number of directory entries
+dw 0
+
+; offset to next directory
+dd 0

Added: commons/proper/imaging/trunk/src/test/data/images/tiff/6/bad-interoperability.tiff
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/data/images/tiff/6/bad-interoperability.tiff?rev=1416148&view=auto
==============================================================================
Binary file - no diff available.

Propchange: commons/proper/imaging/trunk/src/test/data/images/tiff/6/bad-interoperability.tiff
------------------------------------------------------------------------------
    svn:mime-type = image/tiff



Mime
View raw message