Ignore:
Timestamp:
2013-08-09T18:05:11+02:00 (12 years ago)
Author:
bastiK
Message:

applied #8895 - Upgrade metadata-extractor to v. 2.6.4 (patch by ebourg)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/drew/metadata/jpeg/JpegDirectory.java

    r4231 r6127  
    11/*
    2  * This is public domain software - that is, you can do whatever you want
    3  * with it, and include it software that is licensed under the GNU or the
    4  * BSD license, or whatever other licence you choose, including proprietary
    5  * closed source licenses.  I do ask that you leave this header in tact.
     2 * Copyright 2002-2012 Drew Noakes
    63 *
    7  * If you make modifications to this code that you think would benefit the
    8  * wider community, please send me a copy and I'll post it on my site.
     4 *    Licensed under the Apache License, Version 2.0 (the "License");
     5 *    you may not use this file except in compliance with the License.
     6 *    You may obtain a copy of the License at
    97 *
    10  * If you make use of this code, I'd appreciate hearing about it.
    11  *   drew@drewnoakes.com
    12  * Latest version of this software kept at
    13  *   http://drewnoakes.com/
     8 *        http://www.apache.org/licenses/LICENSE-2.0
    149 *
    15  * Created on Aug 2, 2003.
     10 *    Unless required by applicable law or agreed to in writing, software
     11 *    distributed under the License is distributed on an "AS IS" BASIS,
     12 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 *    See the License for the specific language governing permissions and
     14 *    limitations under the License.
     15 *
     16 * More information about this project is available at:
     17 *
     18 *    http://drewnoakes.com/code/exif/
     19 *    http://code.google.com/p/metadata-extractor/
    1620 */
    1721package com.drew.metadata.jpeg;
    1822
     23import com.drew.lang.annotations.NotNull;
     24import com.drew.lang.annotations.Nullable;
    1925import com.drew.metadata.Directory;
    2026import com.drew.metadata.MetadataException;
     
    2430/**
    2531 * Directory of tags and values for the SOF0 Jpeg segment.  This segment holds basic metadata about the image.
    26  * @author Darrell Silver http://www.darrellsilver.com and Drew Noakes
     32 *
     33 * @author Darrell Silver http://www.darrellsilver.com and Drew Noakes http://drewnoakes.com
    2734 */
    28 public class JpegDirectory extends Directory {
    29 
    30         /** This is in bits/sample, usually 8 (12 and 16 not supported by most software). */
    31         public static final int TAG_JPEG_DATA_PRECISION = 0;
    32         /** The image's height.  Necessary for decoding the image, so it should always be there. */
    33         public static final int TAG_JPEG_IMAGE_HEIGHT = 1;
    34         /** The image's width.  Necessary for decoding the image, so it should always be there. */
    35         public static final int TAG_JPEG_IMAGE_WIDTH = 3;
    36         /** Usually 1 = grey scaled, 3 = color YcbCr or YIQ, 4 = color CMYK
    37          * Each component TAG_COMPONENT_DATA_[1-4], has the following meaning:
    38          * component Id(1byte)(1 = Y, 2 = Cb, 3 = Cr, 4 = I, 5 = Q),
    39          * sampling factors (1byte) (bit 0-3 vertical., 4-7 horizontal.),
    40          * quantization table number (1 byte).
    41          * <p>
    42          * This info is from http://www.funducode.com/freec/Fileformats/format3/format3b.htm
    43          */
    44         public static final int TAG_JPEG_NUMBER_OF_COMPONENTS = 5;
     35public class JpegDirectory extends Directory
     36{
     37    public static final int TAG_JPEG_COMPRESSION_TYPE = -3;
     38    /** This is in bits/sample, usually 8 (12 and 16 not supported by most software). */
     39    public static final int TAG_JPEG_DATA_PRECISION = 0;
     40    /** The image's height.  Necessary for decoding the image, so it should always be there. */
     41    public static final int TAG_JPEG_IMAGE_HEIGHT = 1;
     42    /** The image's width.  Necessary for decoding the image, so it should always be there. */
     43    public static final int TAG_JPEG_IMAGE_WIDTH = 3;
     44    /**
     45     * Usually 1 = grey scaled, 3 = color YcbCr or YIQ, 4 = color CMYK
     46     * Each component TAG_COMPONENT_DATA_[1-4], has the following meaning:
     47     * component Id(1byte)(1 = Y, 2 = Cb, 3 = Cr, 4 = I, 5 = Q),
     48     * sampling factors (1byte) (bit 0-3 vertical., 4-7 horizontal.),
     49     * quantization table number (1 byte).
     50     * <p/>
     51     * This info is from http://www.funducode.com/freec/Fileformats/format3/format3b.htm
     52     */
     53    public static final int TAG_JPEG_NUMBER_OF_COMPONENTS = 5;
    4554
    4655    // NOTE!  Component tag type int values must increment in steps of 1
    4756
    48         /** the first of a possible 4 color components.  Number of components specified in TAG_JPEG_NUMBER_OF_COMPONENTS.*/
    49         public static final int TAG_JPEG_COMPONENT_DATA_1 = 6;
    50         /** the second of a possible 4 color components.  Number of components specified in TAG_JPEG_NUMBER_OF_COMPONENTS.*/
    51         public static final int TAG_JPEG_COMPONENT_DATA_2 = 7;
    52         /** the third of a possible 4 color components.  Number of components specified in TAG_JPEG_NUMBER_OF_COMPONENTS.*/
    53         public static final int TAG_JPEG_COMPONENT_DATA_3 = 8;
    54         /** the fourth of a possible 4 color components.  Number of components specified in TAG_JPEG_NUMBER_OF_COMPONENTS.*/
    55         public static final int TAG_JPEG_COMPONENT_DATA_4 = 9;
     57    /** the first of a possible 4 color components.  Number of components specified in TAG_JPEG_NUMBER_OF_COMPONENTS. */
     58    public static final int TAG_JPEG_COMPONENT_DATA_1 = 6;
     59    /** the second of a possible 4 color components.  Number of components specified in TAG_JPEG_NUMBER_OF_COMPONENTS. */
     60    public static final int TAG_JPEG_COMPONENT_DATA_2 = 7;
     61    /** the third of a possible 4 color components.  Number of components specified in TAG_JPEG_NUMBER_OF_COMPONENTS. */
     62    public static final int TAG_JPEG_COMPONENT_DATA_3 = 8;
     63    /** the fourth of a possible 4 color components.  Number of components specified in TAG_JPEG_NUMBER_OF_COMPONENTS. */
     64    public static final int TAG_JPEG_COMPONENT_DATA_4 = 9;
    5665
    57         protected static final HashMap tagNameMap = new HashMap();
     66    @NotNull
     67    protected static final HashMap<Integer, String> _tagNameMap = new HashMap<Integer, String>();
    5868
    59         static {
    60         tagNameMap.put(new Integer(TAG_JPEG_DATA_PRECISION), "Data Precision");
    61         tagNameMap.put(new Integer(TAG_JPEG_IMAGE_WIDTH), "Image Width");
    62         tagNameMap.put(new Integer(TAG_JPEG_IMAGE_HEIGHT), "Image Height");
    63                 tagNameMap.put(new Integer(TAG_JPEG_NUMBER_OF_COMPONENTS), "Number of Components");
    64                 tagNameMap.put(new Integer(TAG_JPEG_COMPONENT_DATA_1), "Component 1");
    65                 tagNameMap.put(new Integer(TAG_JPEG_COMPONENT_DATA_2), "Component 2");
    66                 tagNameMap.put(new Integer(TAG_JPEG_COMPONENT_DATA_3), "Component 3");
    67                 tagNameMap.put(new Integer(TAG_JPEG_COMPONENT_DATA_4), "Component 4");
    68         }
     69    static {
     70        _tagNameMap.put(TAG_JPEG_COMPRESSION_TYPE, "Compression Type");
     71        _tagNameMap.put(TAG_JPEG_DATA_PRECISION, "Data Precision");
     72        _tagNameMap.put(TAG_JPEG_IMAGE_WIDTH, "Image Width");
     73        _tagNameMap.put(TAG_JPEG_IMAGE_HEIGHT, "Image Height");
     74        _tagNameMap.put(TAG_JPEG_NUMBER_OF_COMPONENTS, "Number of Components");
     75        _tagNameMap.put(TAG_JPEG_COMPONENT_DATA_1, "Component 1");
     76        _tagNameMap.put(TAG_JPEG_COMPONENT_DATA_2, "Component 2");
     77        _tagNameMap.put(TAG_JPEG_COMPONENT_DATA_3, "Component 3");
     78        _tagNameMap.put(TAG_JPEG_COMPONENT_DATA_4, "Component 4");
     79    }
    6980
    70     public JpegDirectory() {
    71                 this.setDescriptor(new JpegDescriptor(this));
    72         }
     81    public JpegDirectory()
     82    {
     83        this.setDescriptor(new JpegDescriptor(this));
     84    }
    7385
    74         public String getName() {
    75                 return "Jpeg";
    76         }
     86    @NotNull
     87    public String getName()
     88    {
     89        return "Jpeg";
     90    }
    7791
    78         protected HashMap getTagNameMap() {
    79                 return tagNameMap;
    80         }
     92    @NotNull
     93    protected HashMap<Integer, String> getTagNameMap()
     94    {
     95        return _tagNameMap;
     96    }
    8197
    8298    /**
    83      *
    8499     * @param componentNumber The zero-based index of the component.  This number is normally between 0 and 3.
    85      *        Use getNumberOfComponents for bounds-checking.
    86      * @return
     100     *                        Use getNumberOfComponents for bounds-checking.
     101     * @return the JpegComponent having the specified number.
    87102     */
     103    @Nullable
    88104    public JpegComponent getComponent(int componentNumber)
    89105    {
    90106        int tagType = JpegDirectory.TAG_JPEG_COMPONENT_DATA_1 + componentNumber;
    91 
    92         JpegComponent component = (JpegComponent)getObject(tagType);
    93 
    94         return component;
     107        return (JpegComponent)getObject(tagType);
    95108    }
    96109
Note: See TracChangeset for help on using the changeset viewer.