~ubuntu-branches/ubuntu/saucy/darktable/saucy

« back to all changes in this revision

Viewing changes to src/rawspeed/RawSpeed/TiffEntry.h

  • Committer: Bazaar Package Importer
  • Author(s): David Bremner
  • Date: 2011-08-02 21:32:31 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110802213231-r9v63trgyk1e822j
Tags: 0.9.1-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef TIFF_ENTRY_H
2
 
#define TIFF_ENTRY_H
3
 
 
4
 
#include "TiffParserException.h"
5
 
#include "FileMap.h"
6
 
 
7
 
/* 
8
 
    RawSpeed - RAW file decoder.
9
 
 
10
 
    Copyright (C) 2009 Klaus Post
11
 
 
12
 
    This library is free software; you can redistribute it and/or
13
 
    modify it under the terms of the GNU Lesser General Public
14
 
    License as published by the Free Software Foundation; either
15
 
    version 2 of the License, or (at your option) any later version.
16
 
 
17
 
    This library is distributed in the hope that it will be useful,
18
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
 
    Lesser General Public License for more details.
21
 
 
22
 
    You should have received a copy of the GNU Lesser General Public
23
 
    License along with this library; if not, write to the Free Software
24
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25
 
 
26
 
    http://www.klauspost.com
27
 
*/
28
 
 
29
 
namespace RawSpeed {
30
 
 
31
 
const uint32 datasizes[] = {0,1,1,2,4,8,1,1,2,4, 8, 4, 8, 4};
32
 
                      // 0-1-2-3-4-5-6-7-8-9-10-11-12-13
33
 
const uint32 datashifts[] = {0,0,0,1,2,3,0,0,1,2, 3, 2, 3, 2};
34
 
 
35
 
#ifdef CHECKSIZE
36
 
#undef CHECKSIZE
37
 
#endif
38
 
 
39
 
#define CHECKSIZE(A) if (A >= f->getSize() || A < 1) throw TiffParserException("Error reading TIFF Entry structure size. File Corrupt")
40
 
 
41
 
// 0-1-2-3-4-5-6-7-8-9-10-11-12-13
42
 
/*
43
 
 * Tag data type information.
44
 
 *
45
 
 * Note: RATIONALs are the ratio of two 32-bit integer values.
46
 
 */
47
 
typedef enum {
48
 
        TIFF_NOTYPE     = 0,    /* placeholder */
49
 
        TIFF_BYTE       = 1,    /* 8-bit unsigned integer */
50
 
        TIFF_ASCII      = 2,    /* 8-bit bytes w/ last byte null */
51
 
        TIFF_SHORT      = 3,    /* 16-bit unsigned integer */
52
 
        TIFF_LONG       = 4,    /* 32-bit unsigned integer */
53
 
        TIFF_RATIONAL   = 5,    /* 64-bit unsigned fraction */
54
 
        TIFF_SBYTE      = 6,    /* !8-bit signed integer */
55
 
        TIFF_UNDEFINED  = 7,    /* !8-bit untyped data */
56
 
        TIFF_SSHORT     = 8,    /* !16-bit signed integer */
57
 
        TIFF_SLONG      = 9,    /* !32-bit signed integer */
58
 
        TIFF_SRATIONAL  = 10,   /* !64-bit signed fraction */
59
 
        TIFF_FLOAT      = 11,   /* !32-bit IEEE floating point */
60
 
        TIFF_DOUBLE     = 12    /* !64-bit IEEE floating point */
61
 
} TiffDataType;
62
 
 
63
 
 
64
 
class TiffEntry
65
 
{
66
 
public:
67
 
  TiffEntry();
68
 
  TiffEntry(FileMap* f, uint32 offset);
69
 
  virtual ~TiffEntry(void);
70
 
  virtual uint32 getInt();
71
 
  float getFloat();
72
 
  virtual ushort16 getShort();
73
 
  virtual const uint32* getIntArray();
74
 
  virtual const ushort16* getShortArray();
75
 
  string getString();
76
 
  uchar8 getByte();
77
 
  const uchar8* getData() {return data;};
78
 
  int getElementSize();
79
 
  int getElementShift();
80
 
// variables:
81
 
  TiffTag tag;
82
 
  TiffDataType type;
83
 
  uint32 count;
84
 
  uint32 getDataOffset() const { return data_offset; }
85
 
  bool isFloat();
86
 
  bool isInt();
87
 
protected:
88
 
  uchar8* data;
89
 
  uint32 data_offset;
90
 
#ifdef _DEBUG
91
 
  int debug_intVal;
92
 
  float debug_floatVal;
93
 
#endif
94
 
};
95
 
 
96
 
} // namespace RawSpeed
97
 
 
98
 
#endif