1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
/*
* libopenraw - rawfile.h
*
* Copyright (C) 2005-2006 Hubert Figuiere
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef __RAWFILE_H
#define __RAWFILE_H
#include <string>
#include <vector>
#include <libopenraw/libopenraw.h>
namespace OpenRaw {
namespace IO {
class Stream;
}
class Thumbnail;
class RawData;
class BitmapData;
class MetaValue;
void init();
class RawFile
{
public:
typedef ::or_rawfile_type Type;
typedef ::or_rawfile_typeid TypeId;
/** return a NULL terminated list of file extensions
* that the library handle. This is purely informational.
* @return a pointer the list, NULL terminated. The pointer is
* owned by the library.
*/
static const char **fileExtensions();
/** factory method to create the proper RawFile instance.
* @param _filename the name of the file to load
* @param _typeHint a hint on the type. Use UNKNOWN_TYPE
* if you want to let the library detect it for you.
*/
static RawFile *newRawFile(const char*_filename,
Type _typeHint = OR_RAWFILE_TYPE_UNKNOWN);
/** factory method to create the proper RawFile instance
* from content
* @param buffer the buffer to examine.
* @param len the number of bytes in the length.
* @param _typeHint a hint on the type. Use UNKNOWN_TYPE
* if you want to let the library detect it for you.
*/
static RawFile *newRawFileFromMemory(const uint8_t *buffer, uint32_t len,
Type _typeHint = OR_RAWFILE_TYPE_UNKNOWN);
/** Destructor */
virtual ~RawFile();
/** Accessor for the type */
Type type() const;
/** The RAW file type ID. Identify it if needed.
* @todo figure how to make this const.
*/
TypeId typeId();
// standard api, like get thumbnail
// and get exif.
/** list the available thumbnail sizes
*/
const std::vector<uint32_t> & listThumbnailSizes(void);
/** Get the thumbnail from the raw file
* @param size the square size in px
* @param thumbnail the thumbnail to extract into
* @return the error code
*/
::or_error getThumbnail(uint32_t size, Thumbnail & thumbnail);
/** Get the RAW data
* @param rawdata the RawData to put the data into
* @param options the option bits defined by %or_options
* @return the error code
*/
::or_error getRawData(RawData & rawdata, uint32_t options);
/** Get the rendered image
* @param bitmapdata the BitmapData to put the image into
* @param options the option bits. Pass 0 for now.
* @return the error code
*/
::or_error getRenderedImage(BitmapData & bitmapdata, uint32_t options);
/** Get the orientation of the image, using Exif enums.
*/
int32_t getOrientation();
const MetaValue *getMetaValue(int32_t meta_index);
protected:
struct camera_ids_t {
const char * model;
const uint32_t type_id;
};
/**
* Construct a raw file
* @param s the stream to load from. Take ownership.
* @param _type the type
*/
RawFile(IO::Stream *s, Type _type);
/** Set the file type id */
void _setTypeId(TypeId _type_id);
/** enumerate the thumbnail sizes.
* @param list the list to enumerate into
* @return OR_ERROR_NONE if success
*/
virtual ::or_error _enumThumbnailSizes(std::vector<uint32_t> &list) = 0;
/** get the thumbnail of exact size.
* @param size the size in pixel of the square
* @retval thumbnail the thumbnail to load
* @return OR_ERROR_NONE if success
* @seealso listThumbnailSizes() to understand how to fetch the sizes
* available
*/
virtual ::or_error _getThumbnail(uint32_t size, Thumbnail & thumbnail) = 0;
/** get the RAW data
* @param data the RAW data
* @param option the option bits
* @return OR_ERROR_NONE if success
* Return the data compressed or uncompressed.
*/
virtual ::or_error _getRawData(RawData & data, uint32_t options) = 0;
virtual MetaValue *_getMetaValue(int32_t /*meta_index*/) = 0;
TypeId _typeIdFromModel(const std::string & model);
void _setIdMap(const camera_ids_t *map);
virtual void _identifyId() = 0;
private:
static Type identify(const char*_filename);
static ::or_error identifyBuffer(const uint8_t* buff, size_t len,
Type &_type);
RawFile(const RawFile&);
RawFile & operator=(const RawFile &);
class Private;
Private *d;
};
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0))
indent-tabs-mode:nil
fill-column:80
End:
*/
#endif
|