80 typedef num::NumTraits<size_t>::signedType TSignedSize;
83 typedef std::vector<TPixel> TRaster;
85 typedef prim::ColorRGBA::TValue TValue;
86 typedef prim::ColorRGBA::TParam TParam;
87 typedef prim::ColorRGBA::TNumTraits TNumTraits;
89 typedef TValue (*TFilterFunction)(TValue);
91 typedef prim::Point2D<num::Tfloat32> TChromaticity;
92 enum { numChromaticities = 4 };
101 const TChromaticity& operator[](
size_t index)
const { LASS_ASSERT(index < numChromaticities);
return (&red)[index]; }
102 TChromaticity& operator[](
size_t index) { LASS_ASSERT(index < numChromaticities);
return (&red)[index]; }
103 bool operator==(
const ColorSpace& other)
const
105 return red == other.red && green == other.green && blue == other.blue && white == other.white && gamma == other.gamma;
107 bool operator!=(
const ColorSpace& other)
const {
return !(*
this == other); }
110 class BadFormat:
public util::ExceptionMixin<BadFormat>
113 BadFormat(std::string msg, std::string loc): util::ExceptionMixin<BadFormat>(std::move(msg), std::move(loc)) {}
114 ~BadFormat()
noexcept {}
121 Image(
const std::string& path);
122#if LASS_HAVE_WCHAR_SUPPORT
123 Image(
const std::wstring& path);
125#if LASS_HAVE_STD_FILESYSTEM
126 Image(
const std::filesystem::path& path);
136 void reset(
const std::string& path);
137#if LASS_HAVE_WCHAR_SUPPORT
138 void reset(
const std::wstring& path);
140#if LASS_HAVE_STD_FILESYSTEM
141 void reset(
const std::filesystem::path& path);
145 void open(
const std::string& path);
147 void save(
const std::string& path);
149#if LASS_HAVE_WCHAR_SUPPORT
150 void open(
const std::wstring& path);
151 void save(
const std::wstring& path);
153#if LASS_HAVE_STD_FILESYSTEM
154 void open(
const std::filesystem::path& path);
155 void save(
const std::filesystem::path& path);
161 const TPixel& operator[](
size_t flatIndex)
const {
return raster_[flatIndex]; }
162 TPixel& operator[](
size_t flatIndex) {
return raster_[flatIndex]; }
164 const TPixel&
operator()(
size_t row,
size_t col)
const;
167 const TPixel&
at(TSignedSize row, TSignedSize col)
const;
168 TPixel&
at(TSignedSize row, TSignedSize col);
170 const TPixel*
data()
const;
203 void filter(TFilterFunction function);
210 num::Tuint32 version;
220 num::Tuint8 idLength;
221 num::Tuint8 colorMapType;
222 num::Tuint8 imageType;
223 num::Tuint16 colorMapOrigin;
224 num::Tuint16 colorMapLength;
225 num::Tuint8 colorMapEntrySize;
226 num::Tuint16 imageXorigin;
227 num::Tuint16 imageYorigin;
228 num::Tuint16 imageWidth;
229 num::Tuint16 imageHeight;
230 num::Tuint8 imagePixelSize;
231 num::Tuint8 imageDescriptor;
233 unsigned numAttributeBits()
const {
return imageDescriptor & 0x0F; }
234 bool flipHorizontalFlag()
const {
return ((imageDescriptor >> 4) & 0x01) == 0x01; }
235 bool flipVerticalFlag()
const {
return ((imageDescriptor >> 5) & 0x01) == 0x01; }
236 bool interleavingFlag()
const {
return ((imageDescriptor >> 6) & 0x01) == 0x01; }
242 struct HeaderRadianceHdr
251 float colorCorr[sizeColorCorr];
252 float primaries[sizePrimaries];
258 bool isDefaultPrimaries;
270 num::Endianness endianness;
282 num::Tfloat64 numSamples;
285 num::Tuint32 superSampling;
287 num::Tint32 dataSize;
290 enum { padding = 5000 };
303 FileFormat(TFileOpener iOpen, TFileSaver iSave):
open(iOpen),
save(iSave) {}
307 typedef std::map<std::string, FileFormat> TFileFormats;
309 size_t resize(
size_t rows,
size_t cols);
310 size_t flatIndex(
size_t rows,
size_t cols)
const
328 FileFormat findFormat(
const std::string& formatTag);
329 std::string readRadianceHdrString(
BinaryIStream& stream)
const;
334 static TFileFormats fillFileFormats();
336 static const ColorSpace defaultColorSpace();
337 static const ColorSpace xyzColorSpace();
339 ColorSpace colorSpace_;
344 static TFileFormats fileFormats_;
345 static num::Tuint32 magicLass_;
346 static std::string magicRadiance_;
347 static num::Tint32 magicIgi_;