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/exif/PanasonicMakernoteDirectory.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 by dnoakes on 27-Nov-2002 10:10:47 using IntelliJ IDEA.
     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.exif;
    1822
     23import com.drew.lang.BufferBoundsException;
     24import com.drew.lang.BufferReader;
     25import com.drew.lang.ByteArrayReader;
     26import com.drew.lang.annotations.NotNull;
     27import com.drew.lang.annotations.Nullable;
     28import com.drew.metadata.Age;
    1929import com.drew.metadata.Directory;
     30import com.drew.metadata.Face;
    2031
    2132import java.util.HashMap;
    2233
    2334/**
     35 * Describes tags specific to Panasonic and Leica cameras.
    2436 *
     37 * @author Drew Noakes http://drewnoakes.com, Philipp Sandhaus
    2538 */
    2639public class PanasonicMakernoteDirectory extends Directory
    2740{
    28     public static final int TAG_PANASONIC_QUALITY_MODE = 0x0001;
    29     public static final int TAG_PANASONIC_VERSION = 0x0002;
    30     /**
    31      * 1 = On
    32      * 2 = Off
    33      */
    34     public static final int TAG_PANASONIC_MACRO_MODE = 0x001C;
    35     /**
    36      * 1 = Normal
    37      * 2 = Portrait
    38      * 9 = Macro
    39      */
    40     public static final int TAG_PANASONIC_RECORD_MODE = 0x001F;
    41     public static final int TAG_PANASONIC_PRINT_IMAGE_MATCHING_INFO = 0x0E00;
    42 
    43     protected static final HashMap tagNameMap = new HashMap();
     41
     42    /**
     43     * <br>
     44     * 2 = High            <br>
     45     * 3 = Normal          <br>
     46     * 6 = Very High       <br>
     47     * 7 = Raw             <br>
     48     * 9 = Motion Picture  <br>
     49     */
     50    public static final int TAG_QUALITY_MODE = 0x0001;
     51    public static final int TAG_VERSION = 0x0002;
     52   
     53    /**                   
     54     * <br>
     55     * 1 = Auto            <br>
     56     * 2 = Daylight        <br>
     57     * 3 = Cloudy          <br>
     58     * 4 = Incandescent    <br>
     59     * 5 = Manual          <br>
     60     * 8 = Flash           <br>
     61     * 10 = Black & White  <br>
     62     * 11 = Manual         <br>
     63     * 12 = Shade          <br>
     64     */
     65    public static final int TAG_WHITE_BALANCE = 0x0003;
     66
     67
     68    /**                       
     69     * <br>
     70     * 1 = Auto                <br>
     71     * 2 = Manual              <br>
     72     * 4 =  Auto, Focus Button <br>
     73     * 5 = Auto, Continuous    <br>
     74     */
     75    public static final int TAG_FOCUS_MODE = 0x0007;
     76
     77    /**
     78     * <br>
     79     * 2 bytes                         <br>
     80     * (DMC-FZ10)                      <br>
     81     * '0 1' = Spot Mode On            <br>
     82     * '0 16' = Spot Mode Off          <br>
     83     * '(other models)                 <br>
     84     * 16 = Normal?                    <br>
     85     * '0 1' = 9-area                  <br>
     86     * '0 16' = 3-area (high speed)    <br>
     87     * '1 0' = Spot Focusing           <br>
     88     * '1 1' = 5-area                  <br>
     89     * '16 0' = 1-area                 <br>
     90     * '16 16' = 1-area (high speed)   <br>
     91     * '32 0' = Auto or Face Detect    <br>
     92     * '32 1' = 3-area (left)?         <br>
     93     * '32 2' = 3-area (center)?       <br>
     94     * '32 3' = 3-area (right)?        <br>
     95     * '64 0' = Face Detect            <br>
     96     */
     97    public static final int TAG_AF_AREA_MODE = 0x000f;
     98
     99    /**
     100     * <br>
     101     * 2 = On, Mode 1   <br>
     102     * 3 = Off          <br>
     103     * 4 = On, Mode 2   <br>
     104     */
     105    public static final int TAG_IMAGE_STABILIZATION = 0x001a;
     106
     107    /**
     108     * <br>
     109     * 1 = On    <br>
     110     * 2 = Off   <br>
     111     */
     112    public static final int TAG_MACRO_MODE = 0x001C;
     113
     114    /**
     115     * <br>
     116     * 1 = Normal                            <br>
     117     * 2 = Portrait                          <br>
     118     * 3 = Scenery                           <br>
     119     * 4 = Sports                            <br>
     120     * 5 = Night Portrait                    <br>
     121     * 6 = Program                           <br>
     122     * 7 = Aperture Priority                 <br>
     123     * 8 = Shutter Priority                  <br>
     124     * 9 = Macro                             <br>
     125     * 10= Spot                              <br>
     126     * 11= Manual                            <br>
     127     * 12= Movie Preview                     <br>
     128     * 13= Panning                           <br>
     129     * 14= Simple                            <br>
     130     * 15= Color Effects                     <br>
     131     * 16= Self Portrait                     <br>
     132     * 17= Economy                           <br>
     133     * 18= Fireworks                         <br>
     134     * 19= Party                             <br>
     135     * 20= Snow                              <br>
     136     * 21= Night Scenery                     <br>
     137     * 22= Food                              <br>
     138     * 23= Baby                              <br>
     139     * 24= Soft Skin                         <br>
     140     * 25= Candlelight                       <br>
     141     * 26= Starry Night                      <br>
     142     * 27= High Sensitivity                  <br>
     143     * 28= Panorama Assist                   <br>
     144     * 29= Underwater                        <br>
     145     * 30= Beach                             <br>
     146     * 31= Aerial Photo                      <br>
     147     * 32= Sunset                            <br>
     148     * 33= Pet                               <br>
     149     * 34= Intelligent ISO                   <br>
     150     * 35= Clipboard                         <br>
     151     * 36= High Speed Continuous Shooting    <br>
     152     * 37= Intelligent Auto                  <br>
     153     * 39= Multi-aspect                      <br>
     154     * 41= Transform                         <br>
     155     * 42= Flash Burst                       <br>
     156     * 43= Pin Hole                          <br>
     157     * 44= Film Grain                        <br>
     158     * 45= My Color                          <br>
     159     * 46= Photo Frame                       <br>
     160     * 51= HDR                               <br>
     161     */
     162    public static final int TAG_RECORD_MODE = 0x001F;
     163   
     164    /**
     165     * 1 = Yes <br>
     166     * 2 = No  <br>
     167     */
     168    public static final int TAG_AUDIO = 0x0020;
     169
     170    /**
     171     * No idea, what this is
     172     */
     173    public static final int TAG_UNKNOWN_DATA_DUMP = 0x0021;
     174   
     175    public static final int TAG_WHITE_BALANCE_BIAS = 0x0023;
     176    public static final int TAG_FLASH_BIAS = 0x0024;
     177   
     178    /**
     179     * this number is unique, and contains the date of manufacture,
     180     * but is not the same as the number printed on the camera body
     181     */
     182    public static final int TAG_INTERNAL_SERIAL_NUMBER = 0x0025;
     183
     184    /**
     185     * Panasonic Exif Version
     186     */
     187    public static final int TAG_EXIF_VERSION = 0x0026;
     188   
     189   
     190    /**
     191     * 1 = Off           <br>
     192     * 2 = Warm          <br>
     193     * 3 = Cool          <br>
     194     * 4 = Black & White <br>
     195     * 5 = Sepia         <br>
     196     */
     197    public static final int TAG_COLOR_EFFECT = 0x0028;
     198
     199    /**
     200     * 4 Bytes <br>
     201     * Time in 1/100 s from when the camera was powered on to when the
     202     * image is written to memory card
     203     */
     204    public static final int TAG_UPTIME = 0x0029;
     205
     206
     207    /**
     208     * 0 = Off        <br>
     209     * 1 = On         <br>
     210     * 2 = Infinite   <br>
     211     * 4 = Unlimited  <br>
     212     */
     213    public static final int TAG_BURST_MODE = 0x002a;
     214   
     215    public static final int TAG_SEQUENCE_NUMBER = 0x002b;
     216   
     217    /**
     218     * (this decoding seems to work for some models such as the LC1, LX2, FZ7, FZ8, FZ18 and FZ50, but may not be correct for other models such as the FX10, G1, L1, L10 and LC80) <br>
     219     * 0x0 = Normal                                            <br>
     220     * 0x1 = Low                                               <br>
     221     * 0x2 = High                                              <br>
     222     * 0x6 = Medium Low                                        <br>
     223     * 0x7 = Medium High                                       <br>
     224     * 0x100 = Low                                             <br>
     225     * 0x110 = Normal                                          <br>
     226     * 0x120 = High                                            <br>
     227     * (these values are used by the GF1)                      <br>
     228     * 0 = -2                                                  <br>
     229     * 1 = -1                                                  <br>
     230     * 2 = Normal                                              <br>
     231     * 3 = +1                                                  <br>
     232     * 4 = +2                                                  <br>
     233     * 7 = Nature (Color Film)                                 <br>
     234     * 12 = Smooth (Color Film) or Pure (My Color)             <br>
     235     * 17 = Dynamic (B&W Film)                                 <br>
     236     * 22 = Smooth (B&W Film)                                  <br>
     237     * 27 = Dynamic (Color Film)                               <br>
     238     * 32 = Vibrant (Color Film) or Expressive (My Color)      <br>
     239     * 33 = Elegant (My Color)                                 <br>
     240     * 37 = Nostalgic (Color Film)                             <br>
     241     * 41 = Dynamic Art (My Color)                             <br>
     242     * 42 = Retro (My Color)                                   <br>
     243     */
     244    public static final int TAG_CONTRAST_MODE = 0x002c;
     245   
     246   
     247    /**
     248     * 0 = Standard      <br>
     249     * 1 = Low (-1)      <br>
     250     * 2 = High (+1)     <br>
     251     * 3 = Lowest (-2)   <br>
     252     * 4 = Highest (+2)  <br>
     253     */
     254    public static final int TAG_NOISE_REDUCTION = 0x002d;
     255
     256    /**
     257     * 1 = Off   <br>
     258     * 2 = 10 s  <br>
     259     * 3 = 2 s   <br>
     260     */
     261    public static final int TAG_SELF_TIMER = 0x002e;
     262
     263    /**
     264     * 1 = 0 DG    <br>
     265     * 3 = 180 DG  <br>
     266     * 6 =  90 DG  <br>
     267     * 8 = 270 DG  <br>
     268     */
     269    public static final int TAG_ROTATION = 0x0030;
     270
     271    /**
     272     * 1 = Fired <br>
     273     * 2 = Enabled nut not used <br>
     274     * 3 = Disabled but required <br>
     275     * 4 = Disabled and not required
     276     */
     277    public static final int TAG_AF_ASSIST_LAMP = 0x0031;
     278   
     279    /**
     280     * 0 = Normal <br>
     281     * 1 = Natural<br>
     282     * 2 = Vivid
     283     *
     284     */
     285    public static final int TAG_COLOR_MODE = 0x0032;
     286   
     287    public static final int TAG_BABY_AGE = 0x0033;
     288   
     289    /**
     290     *  1 = Standard <br>
     291     *  2 = Extended
     292     */
     293    public static final int TAG_OPTICAL_ZOOM_MODE = 0x0034;
     294   
     295    /**
     296     * 1 = Off <br>
     297     * 2 = Wide <br>
     298     * 3 = Telephoto <br>
     299     * 4 = Macro
     300     */
     301    public static final int TAG_CONVERSION_LENS = 0x0035;
     302   
     303    public static final int TAG_TRAVEL_DAY = 0x0036;
     304   
     305    /**
     306     * 0 = Normal
     307     */
     308    public static final int TAG_CONTRAST = 0x0039;
     309   
     310    /**
     311     * <br>
     312     * 1 = Home <br>
     313     * 2 = Destination
     314     */
     315    public static final int TAG_WORLD_TIME_LOCATION = 0x003a;
     316   
     317    /**
     318     * 1 = Off   <br>
     319     * 2 = On
     320     */
     321    public static final int TAG_TEXT_STAMP = 0x003b;
     322
     323        public static final int TAG_PROGRAM_ISO = 0x003c;
     324   
     325    /**
     326     * <br>
     327     * 1 = Normal                               <br>
     328     * 2 = Outdoor/Illuminations/Flower/HDR Art <br>
     329     * 3 = Indoor/Architecture/Objects/HDR B&W  <br>
     330     * 4 = Creative                             <br>
     331     * 5 = Auto                                 <br>
     332     * 7 = Expressive                           <br>
     333     * 8 = Retro                                <br>
     334     * 9 = Pure                                 <br>
     335     * 10 = Elegant                             <br>
     336     * 12 = Monochrome                          <br>
     337     * 13 = Dynamic Art                         <br>
     338     * 14 = Silhouette                          <br>
     339     */
     340    public static final int TAG_ADVANCED_SCENE_MODE = 0x003d;
     341   
     342    /**
     343     * 1 = Off   <br>
     344     * 2 = On
     345     */
     346    public static final int TAG_TEXT_STAMP_1 = 0x003e;
     347       
     348    public static final int TAG_FACES_DETECTED = 0x003f;
     349
     350    public static final int TAG_SATURATION = 0x0040;
     351    public static final int TAG_SHARPNESS = 0x0041;
     352    public static final int TAG_FILM_MODE = 0x0042;
     353
     354    /**
     355         * WB adjust AB. Positive is a shift toward blue.
     356         */
     357        public static final int TAG_WB_ADJUST_AB = 0x0046;
     358    /**
     359         * WB adjust GM. Positive is a shift toward green.
     360         */
     361        public static final int TAG_WB_ADJUST_GM = 0x0047;
     362       
     363
     364    public static final int TAG_AF_POINT_POSITION = 0x004d;
     365   
     366   
     367    /**
     368     * <br>
     369     * Integer (16Bit) Indexes:                                             <br>
     370     * 0  Number Face Positions (maybe less than Faces Detected)            <br>
     371     * 1-4 Face Position 1                                                  <br>
     372     * 5-8 Face Position 2                                                  <br>
     373     * and so on                                                            <br>
     374     *                                                                      <br>
     375     * The four Integers are interpreted as follows:                        <br>
     376     * (XYWH)  X,Y Center of Face,  (W,H) Width and Height                  <br>
     377     * All values are in respect to double the size of the thumbnail image  <br>
     378     *
     379     */
     380    public static final int TAG_FACE_DETECTION_INFO = 0x004e;
     381    public static final int TAG_LENS_TYPE = 0x0051;
     382    public static final int TAG_LENS_SERIAL_NUMBER = 0x0052;
     383    public static final int TAG_ACCESSORY_TYPE = 0x0053;
     384   
     385    /**
     386     * (decoded as two 16-bit signed integers)
     387     * '-1 1' = Slim Low
     388     * '-3 2' = Slim High
     389     * '0 0' = Off
     390     * '1 1' = Stretch Low
     391     * '3 2' = Stretch High 
     392     */
     393    public static final int TAG_TRANSFORM = 0x0059;
     394   
     395    /**
     396    * 0 = Off <br>
     397    * 1 = Low <br>
     398    * 2 = Standard <br>
     399    * 3 = High
     400    */
     401    public static final int TAG_INTELLIGENT_EXPOSURE = 0x005d;
     402   
     403    /**
     404          * Info at http://www.ozhiker.com/electronics/pjmt/jpeg_info/pim.html
     405          *
     406     */
     407        public static final int TAG_PRINT_IMAGE_MATCHING_INFO = 0x0E00;
     408
     409
     410
     411    /**                                                                                   
     412     * Byte Indexes:                                                                       <br>
     413     *  0    Int (2  Byte) Number of Recognized Faces                                      <br>
     414     *  4    String(20 Byte)    Recognized Face 1 Name                                     <br>
     415     * 24    4 Int (8 Byte)     Recognized Face 1 Position  (Same Format as Face Detection)  <br>
     416     * 32    String(20 Byte)    Recognized Face 1 Age                                      <br>
     417     * 52    String(20 Byte)    Recognized Face 2 Name                                     <br>
     418     * 72    4 Int (8 Byte)     Recognized Face 2 Position  (Same Format as Face Detection)  <br>
     419     * 80    String(20 Byte)    Recognized Face 2 Age                                      <br>
     420     *                                                                                     <br>
     421     * And so on                                                                           <br>
     422     *                                                                                     <br>
     423     * The four Integers are interpreted as follows:                                       <br>
     424     * (XYWH)  X,Y Center of Face,  (W,H) Width and Height                                 <br>
     425     * All values are in respect to double the size of the thumbnail image                 <br>
     426     *
     427     */
     428    public static final int TAG_FACE_RECOGNITION_INFO = 0x0061;
     429
     430    /**
     431    * 0 = No <br>
     432    * 1 = Yes
     433    */
     434    public static final int TAG_FLASH_WARNING = 0x0062;
     435    public static final int TAG_RECOGNIZED_FACE_FLAGS = 0x0063;
     436    public static final int TAG_TITLE = 0x0065;
     437        public static final int TAG_BABY_NAME = 0x0066;
     438        public static final int TAG_LOCATION = 0x0067;
     439        public static final int TAG_COUNTRY = 0x0069;
     440    public static final int TAG_STATE = 0x006b;
     441    public static final int TAG_CITY = 0x006d;
     442    public static final int TAG_LANDMARK = 0x006f;
     443   
     444    /**
     445     * 0 = Off <br>
     446     * 2 = Auto <br>
     447     * 3 = On
     448     */
     449    public static final int TAG_INTELLIGENT_RESOLUTION = 0x0070;
     450   
     451    public static final int TAG_MAKERNOTE_VERSION = 0x8000;
     452    public static final int TAG_SCENE_MODE = 0x8001;
     453    public static final int TAG_WB_RED_LEVEL = 0x8004;
     454    public static final int TAG_WB_GREEN_LEVEL = 0x8005;
     455    public static final int TAG_WB_BLUE_LEVEL = 0x8006;
     456    public static final int TAG_FLASH_FIRED = 0x8007;
     457    public static final int TAG_TEXT_STAMP_2 = 0x8008;
     458        public static final int TAG_TEXT_STAMP_3 = 0x8009;
     459        public static final int TAG_BABY_AGE_1 = 0x8010;
     460       
     461        /**
     462     * (decoded as two 16-bit signed integers)
     463     * '-1 1' = Slim Low
     464     * '-3 2' = Slim High
     465     * '0 0' = Off
     466     * '1 1' = Stretch Low
     467     * '3 2' = Stretch High 
     468     */
     469    public static final int TAG_TRANSFORM_1 = 0x8012;
     470
     471    @NotNull
     472    protected static final HashMap<Integer, String> _tagNameMap = new HashMap<Integer, String>();
    44473
    45474    static
    46475    {
    47         tagNameMap.put(new Integer(TAG_PANASONIC_QUALITY_MODE), "Quality Mode");
    48         tagNameMap.put(new Integer(TAG_PANASONIC_VERSION), "Version");
    49         tagNameMap.put(new Integer(TAG_PANASONIC_MACRO_MODE), "Macro Mode");
    50         tagNameMap.put(new Integer(TAG_PANASONIC_RECORD_MODE), "Record Mode");
    51         tagNameMap.put(new Integer(TAG_PANASONIC_PRINT_IMAGE_MATCHING_INFO), "Print Image Matching (PIM) Info");
     476        _tagNameMap.put(TAG_QUALITY_MODE, "Quality Mode");
     477        _tagNameMap.put(TAG_VERSION, "Version");
     478        _tagNameMap.put(TAG_WHITE_BALANCE, "White Balance");
     479        _tagNameMap.put(TAG_FOCUS_MODE, "Focus Mode");
     480        _tagNameMap.put(TAG_AF_AREA_MODE, "AF Area Mode");
     481        _tagNameMap.put(TAG_IMAGE_STABILIZATION, "Image Stabilization");
     482        _tagNameMap.put(TAG_MACRO_MODE, "Macro Mode");
     483        _tagNameMap.put(TAG_RECORD_MODE, "Record Mode");
     484        _tagNameMap.put(TAG_AUDIO, "Audio");
     485        _tagNameMap.put(TAG_INTERNAL_SERIAL_NUMBER, "Internal Serial Number");
     486        _tagNameMap.put(TAG_UNKNOWN_DATA_DUMP, "Unknown Data Dump");
     487        _tagNameMap.put(TAG_WHITE_BALANCE_BIAS, "White Balance Bias");
     488        _tagNameMap.put(TAG_FLASH_BIAS, "Flash Bias");
     489        _tagNameMap.put(TAG_EXIF_VERSION, "Exif Version");
     490        _tagNameMap.put(TAG_COLOR_EFFECT, "Color Effect");
     491        _tagNameMap.put(TAG_UPTIME, "Camera Uptime");
     492        _tagNameMap.put(TAG_BURST_MODE, "Burst Mode");
     493        _tagNameMap.put(TAG_SEQUENCE_NUMBER, "Sequence Number");
     494        _tagNameMap.put(TAG_CONTRAST_MODE, "Contrast Mode");
     495        _tagNameMap.put(TAG_NOISE_REDUCTION, "Noise Reduction");
     496        _tagNameMap.put(TAG_SELF_TIMER, "Self Timer");
     497        _tagNameMap.put(TAG_ROTATION, "Rotation");
     498        _tagNameMap.put(TAG_AF_ASSIST_LAMP, "AF Assist Lamp");
     499        _tagNameMap.put(TAG_COLOR_MODE, "Color Mode");
     500        _tagNameMap.put(TAG_BABY_AGE, "Baby Age");
     501        _tagNameMap.put(TAG_OPTICAL_ZOOM_MODE, "Optical Zoom Mode");
     502        _tagNameMap.put(TAG_CONVERSION_LENS, "Conversion Lens");
     503        _tagNameMap.put(TAG_TRAVEL_DAY, "Travel Day");
     504        _tagNameMap.put(TAG_CONTRAST, "Contrast");
     505        _tagNameMap.put(TAG_WORLD_TIME_LOCATION, "World Time Location");
     506        _tagNameMap.put(TAG_TEXT_STAMP, "Text Stamp");
     507        _tagNameMap.put(TAG_PROGRAM_ISO, "Program ISO");
     508                _tagNameMap.put(TAG_ADVANCED_SCENE_MODE, "Advanced Scene Mode");
     509        _tagNameMap.put(TAG_PRINT_IMAGE_MATCHING_INFO, "Print Image Matching (PIM) Info");
     510        _tagNameMap.put(TAG_FACES_DETECTED, "Number of Detected Faces");
     511        _tagNameMap.put(TAG_SATURATION, "Saturation");
     512        _tagNameMap.put(TAG_SHARPNESS, "Sharpness");
     513        _tagNameMap.put(TAG_FILM_MODE, "Film Mode");
     514        _tagNameMap.put(TAG_WB_ADJUST_AB, "White Balance Adjust (AB)");
     515                _tagNameMap.put(TAG_WB_ADJUST_GM, "White Balance Adjust (GM)");
     516                _tagNameMap.put(TAG_AF_POINT_POSITION, "Af Point Position");
     517        _tagNameMap.put(TAG_FACE_DETECTION_INFO, "Face Detection Info");
     518        _tagNameMap.put(TAG_LENS_TYPE, "Lens Type");
     519        _tagNameMap.put(TAG_LENS_SERIAL_NUMBER, "Lens Serial Number");
     520        _tagNameMap.put(TAG_ACCESSORY_TYPE, "Accessory Type");
     521        _tagNameMap.put(TAG_TRANSFORM, "Transform");
     522        _tagNameMap.put(TAG_INTELLIGENT_EXPOSURE, "Intelligent Exposure");
     523        _tagNameMap.put(TAG_FACE_RECOGNITION_INFO, "Face Recognition Info");
     524        _tagNameMap.put(TAG_FLASH_WARNING, "Flash Warning");
     525        _tagNameMap.put(TAG_RECOGNIZED_FACE_FLAGS, "Recognized Face Flags");
     526                _tagNameMap.put(TAG_TITLE, "Title");
     527                _tagNameMap.put(TAG_BABY_NAME, "Baby Name");
     528                _tagNameMap.put(TAG_LOCATION, "Location");
     529                _tagNameMap.put(TAG_COUNTRY, "Country");
     530        _tagNameMap.put(TAG_STATE, "State");
     531        _tagNameMap.put(TAG_CITY, "City");
     532        _tagNameMap.put(TAG_LANDMARK, "Landmark");
     533        _tagNameMap.put(TAG_INTELLIGENT_RESOLUTION, "Intelligent Resolution");
     534        _tagNameMap.put(TAG_MAKERNOTE_VERSION, "Makernote Version");
     535        _tagNameMap.put(TAG_SCENE_MODE, "Scene Mode");
     536        _tagNameMap.put(TAG_WB_RED_LEVEL, "White Balance (Red)");
     537        _tagNameMap.put(TAG_WB_GREEN_LEVEL, "White Balance (Green)");
     538        _tagNameMap.put(TAG_WB_BLUE_LEVEL, "White Balance (Blue)");
     539        _tagNameMap.put(TAG_FLASH_FIRED, "Flash Fired");
     540                _tagNameMap.put(TAG_TEXT_STAMP_1, "Text Stamp 1");
     541                _tagNameMap.put(TAG_TEXT_STAMP_2, "Text Stamp 2");
     542                _tagNameMap.put(TAG_TEXT_STAMP_3, "Text Stamp 3");
     543                _tagNameMap.put(TAG_BABY_AGE_1, "Baby Age 1");
     544                _tagNameMap.put(TAG_TRANSFORM_1, "Transform 1");
    52545    }
    53546
     
    57550    }
    58551
     552    @NotNull
    59553    public String getName()
    60554    {
     
    62556    }
    63557
    64     protected HashMap getTagNameMap()
     558    @NotNull
     559    protected HashMap<Integer, String> getTagNameMap()
    65560    {
    66         return tagNameMap;
     561        return _tagNameMap;
    67562    }
     563
     564    @Nullable
     565    public Face[] getDetectedFaces()
     566    {
     567        byte[] bytes = getByteArray(PanasonicMakernoteDirectory.TAG_FACE_DETECTION_INFO);
     568        if (bytes==null)
     569            return null;
     570
     571        BufferReader reader = new ByteArrayReader(bytes);
     572        reader.setMotorolaByteOrder(false);
     573       
     574        try {
     575            int faceCount = reader.getUInt16(0);
     576            if (faceCount==0)
     577                return null;
     578            Face[] faces = new Face[faceCount];
     579
     580            for (int i = 0; i < faceCount; i++) {
     581                int offset = 2 + i * 8;
     582                faces[i] = new Face(
     583                        reader.getUInt16(offset),
     584                        reader.getUInt16(offset + 2),
     585                        reader.getUInt16(offset + 4),
     586                        reader.getUInt16(offset + 6)
     587                        , null, null);
     588            }
     589            return faces;
     590        } catch (BufferBoundsException e) {
     591            return null;
     592        }
     593    }
     594
     595    @Nullable
     596    public Face[] getRecognizedFaces()
     597    {
     598        byte[] bytes = getByteArray(PanasonicMakernoteDirectory.TAG_FACE_RECOGNITION_INFO);
     599        if (bytes == null)
     600            return null;
     601
     602        BufferReader reader = new ByteArrayReader(bytes);
     603        reader.setMotorolaByteOrder(false);
     604
     605        try {
     606            int faceCount = reader.getUInt16(0);
     607            if (faceCount==0)
     608                return null;
     609            Face[] faces = new Face[faceCount];
     610
     611            for (int i = 0; i < faceCount; i++) {
     612                int offset = 4 + i * 44;
     613                String name = reader.getString(offset, 20, "ASCII").trim();
     614                String age = reader.getString(offset + 28, 20, "ASCII").trim();
     615                faces[i] = new Face(
     616                        reader.getUInt16(offset + 20),
     617                        reader.getUInt16(offset + 22),
     618                        reader.getUInt16(offset + 24),
     619                        reader.getUInt16(offset + 26),
     620                        name,
     621                        Age.fromPanasonicString(age));
     622            }
     623            return faces;
     624        } catch (BufferBoundsException e) {
     625            return null;
     626        }
     627    }
     628
     629    /**
     630     * Attempts to convert the underlying string value (as stored in the directory) into an Age object.
     631     * @param tag The tag identifier.
     632     * @return The parsed Age object, or null if the tag was empty of the value unable to be parsed.
     633     */
     634        @Nullable
     635        public Age getAge(int tag)
     636    {
     637        final String ageString = getString(tag);
     638        if (ageString==null)
     639            return null;
     640        return Age.fromPanasonicString(ageString);
     641        }
    68642}
Note: See TracChangeset for help on using the changeset viewer.