libopenraw
rawfile.h
1 /*
2  * libopenraw - rawfile.h
3  *
4  * Copyright (C) 2005-2006 Hubert Figuiere
5  *
6  * This library is free software: you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation, either version 3 of
9  * the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 
23 #ifndef __RAWFILE_H
24 #define __RAWFILE_H
25 
26 #include <string>
27 #include <vector>
28 
29 #include <libopenraw/libopenraw.h>
30 
31 namespace OpenRaw {
32 
33 namespace IO {
34 class Stream;
35 }
36 class Thumbnail;
37 class RawData;
38 class BitmapData;
39 class MetaValue;
40 
41 void init();
42 
43 class RawFile
44 {
45 public:
46  typedef ::or_rawfile_type Type;
47  typedef ::or_rawfile_typeid TypeId;
48 
49 
55  static const char **fileExtensions();
56 
62  static RawFile *newRawFile(const char*_filename,
63  Type _typeHint = OR_RAWFILE_TYPE_UNKNOWN);
71  static RawFile *newRawFileFromMemory(const uint8_t *buffer, uint32_t len,
72  Type _typeHint = OR_RAWFILE_TYPE_UNKNOWN);
73 
75  virtual ~RawFile();
77  Type type() const;
78 
82  TypeId typeId();
83 
84  // standard api, like get thumbnail
85  // and get exif.
86 
89  const std::vector<uint32_t> & listThumbnailSizes(void);
95  ::or_error getThumbnail(uint32_t size, Thumbnail & thumbnail);
96 
102  ::or_error getRawData(RawData & rawdata, uint32_t options);
103 
109  ::or_error getRenderedImage(BitmapData & bitmapdata, uint32_t options);
110 
113  int32_t getOrientation();
114 
115  const MetaValue *getMetaValue(int32_t meta_index);
116 protected:
117  struct camera_ids_t {
118  const char * model;
119  const uint32_t type_id;
120  };
126  RawFile(IO::Stream *s, Type _type);
127 
129  void _setTypeId(TypeId _type_id);
130 
135  virtual ::or_error _enumThumbnailSizes(std::vector<uint32_t> &list) = 0;
136 
144  virtual ::or_error _getThumbnail(uint32_t size, Thumbnail & thumbnail) = 0;
151  virtual ::or_error _getRawData(RawData & data, uint32_t options) = 0;
152 
153  virtual MetaValue *_getMetaValue(int32_t /*meta_index*/) = 0;
154 
155  TypeId _typeIdFromModel(const std::string & model);
156  void _setIdMap(const camera_ids_t *map);
157  virtual void _identifyId() = 0;
158 private:
159  static Type identify(const char*_filename);
160  static ::or_error identifyBuffer(const uint8_t* buff, size_t len,
161  Type &_type);
162 
163 
164  RawFile(const RawFile&);
165  RawFile & operator=(const RawFile &);
166 
167  class Private;
168 
169  Private *d;
170 };
171 
172 
173 
174 }
175 
176 /*
177  Local Variables:
178  mode:c++
179  c-file-style:"stroustrup"
180  c-file-offsets:((innamespace . 0))
181  indent-tabs-mode:nil
182  fill-column:80
183  End:
184 */
185 #endif