libopenraw

rawfile.h

00001 /*
00002  * libopenraw - rawfile.h
00003  *
00004  * Copyright (C) 2005-2006 Hubert Figuiere
00005  *
00006  * This library is free software: you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public License
00008  * as published by the Free Software Foundation, either version 3 of
00009  * the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library.  If not, see
00018  * <http://www.gnu.org/licenses/>.
00019  */
00020 
00021 
00022 
00023 #ifndef __RAWFILE_H
00024 #define __RAWFILE_H
00025 
00026 #include <string>
00027 #include <vector>
00028 
00029 #include <libopenraw/libopenraw.h>
00030 
00031 namespace OpenRaw {
00032 
00033 namespace IO {
00034 class Stream;
00035 }
00036 class Thumbnail;
00037 class RawData;
00038 class BitmapData;
00039 class MetaValue;
00040 
00041 void init();
00042 
00043 class RawFile
00044 {
00045 public:
00046     typedef ::or_rawfile_type Type;
00047     typedef ::or_rawfile_typeid TypeId;
00048 
00049 
00055     static const char **fileExtensions();
00056 
00062     static RawFile *newRawFile(const char*_filename, 
00063                                Type _typeHint = OR_RAWFILE_TYPE_UNKNOWN);
00071     static RawFile *newRawFileFromMemory(const uint8_t *buffer, uint32_t len, 
00072                                          Type _typeHint = OR_RAWFILE_TYPE_UNKNOWN);
00073 
00075     virtual ~RawFile();
00077     Type type() const;
00078 
00082     TypeId typeId();
00083 
00084     // standard api, like get thumbnail
00085     // and get exif.
00086 
00089     const std::vector<uint32_t> & listThumbnailSizes(void);
00095     ::or_error getThumbnail(uint32_t size, Thumbnail & thumbnail);
00096 
00102     ::or_error getRawData(RawData & rawdata, uint32_t options);
00103 
00109     ::or_error getRenderedImage(BitmapData & bitmapdata, uint32_t options);    
00110 
00113     int32_t getOrientation();
00114 
00115     const MetaValue *getMetaValue(int32_t meta_index);
00116 protected:
00117     struct camera_ids_t {
00118         const char * model;
00119         const uint32_t type_id;
00120     };
00126     RawFile(IO::Stream *s, Type _type);
00127 
00129     void _setTypeId(TypeId _type_id);
00130 
00135     virtual ::or_error _enumThumbnailSizes(std::vector<uint32_t> &list) = 0;
00136         
00144     virtual ::or_error _getThumbnail(uint32_t size, Thumbnail & thumbnail) = 0;
00151     virtual ::or_error _getRawData(RawData & data, uint32_t options) = 0;
00152 
00153     virtual MetaValue *_getMetaValue(int32_t /*meta_index*/) = 0;
00154 
00155     TypeId _typeIdFromModel(const std::string & model);
00156     void _setIdMap(const camera_ids_t *map);
00157     virtual void _identifyId() = 0;
00158 private:
00159     static Type identify(const char*_filename);
00160     static ::or_error identifyBuffer(const uint8_t* buff, size_t len,
00161                                      Type &_type);
00162 
00163 
00164     RawFile(const RawFile&);
00165     RawFile & operator=(const RawFile &);
00166 
00167     class Private;
00168 
00169     Private *d;
00170 };
00171 
00172 
00173 
00174 }
00175 
00176 /*
00177   Local Variables:
00178   mode:c++
00179   c-file-style:"stroustrup"
00180   c-file-offsets:((innamespace . 0))
00181   indent-tabs-mode:nil
00182   fill-column:80
00183   End:
00184 */
00185 #endif