⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imfheader.h

📁 image converter source code
💻 H
📖 第 1 页 / 共 2 页
字号:
    //-------------------------------------------------------------    // Sanity check -- examines the header, and throws an exception    // if it finds something wrong (empty display window, negative    // pixel aspect ratio, unknown compression sceme etc.)    //    // set isTiled to true if you are checking a tiled/multi-res    // header    //-------------------------------------------------------------    void			sanityCheck (bool isTiled = false) const;    //----------------------------------------------------------------    // Maximum image size and maximim tile size:    //    // sanityCheck() will throw an exception if the width or height of    // the data window exceeds the maximum image width or height, or    // if the size of a tile exceeds the maximum tile width or height.    //     // At program startup the maximum image and tile width and height    // are set to zero, meaning that width and height are unlimited.    //    // Limiting image and tile width and height limits how much memory    // will be allocated when a file is opened.  This can help protect    // applications from running out of memory while trying to read    // a damaged image file.    //----------------------------------------------------------------    static void			setMaxImageSize (int maxWidth, int maxHeight);    static void			setMaxTileSize (int maxWidth, int maxHeight);    //------------------------------------------------------------------    // Input and output:    //    // If the header contains a preview image attribute, then writeTo()    // returns the position of that attribute in the output stream; this    // information is used by OutputFile::updatePreviewImage().    // If the header contains no preview image attribute, then writeTo()    // returns 0.    //------------------------------------------------------------------    Int64			writeTo (OStream &os,					 bool isTiled = false) const;    void			readFrom (IStream &is, int &version);  private:    AttributeMap		_map;};//----------// Iterators//----------class Header::Iterator{  public:    Iterator ();    Iterator (const Header::AttributeMap::iterator &i);    Iterator &			operator ++ ();    Iterator 			operator ++ (int);    const char *		name () const;    Attribute &			attribute () const;  private:    friend class Header::ConstIterator;    Header::AttributeMap::iterator _i;};class Header::ConstIterator{  public:    ConstIterator ();    ConstIterator (const Header::AttributeMap::const_iterator &i);    ConstIterator (const Header::Iterator &other);    ConstIterator &		operator ++ ();    ConstIterator 		operator ++ (int);    const char *		name () const;    const Attribute &		attribute () const;  private:    friend bool operator == (const ConstIterator &, const ConstIterator &);    friend bool operator != (const ConstIterator &, const ConstIterator &);    Header::AttributeMap::const_iterator _i;};//------------------------------------------------------------------------// Library initialization://// In a multithreaded program, staticInitialize() must be called once// during startup, before the program accesses any other functions or// classes in the IlmImf library.  Calling staticInitialize() in this// way avoids races during initialization of the library's global// variables.//// Single-threaded programs are not required to call staticInitialize();// initialization of the library's global variables happens automatically.////------------------------------------------------------------------------void staticInitialize ();//-----------------// Inline Functions//-----------------inlineHeader::Iterator::Iterator (): _i(){    // empty}inlineHeader::Iterator::Iterator (const Header::AttributeMap::iterator &i): _i (i){    // empty}inline Header::Iterator &		Header::Iterator::operator ++ (){    ++_i;    return *this;}inline Header::Iterator 	Header::Iterator::operator ++ (int){    Iterator tmp = *this;    ++_i;    return tmp;}inline const char *Header::Iterator::name () const{    return *_i->first;}inline Attribute &	Header::Iterator::attribute () const{    return *_i->second;}inlineHeader::ConstIterator::ConstIterator (): _i(){    // empty}inlineHeader::ConstIterator::ConstIterator    (const Header::AttributeMap::const_iterator &i): _i (i){    // empty}inlineHeader::ConstIterator::ConstIterator (const Header::Iterator &other):    _i (other._i){    // empty}inline Header::ConstIterator &Header::ConstIterator::operator ++ (){    ++_i;    return *this;}inline Header::ConstIterator 		Header::ConstIterator::operator ++ (int){    ConstIterator tmp = *this;    ++_i;    return tmp;}inline const char *Header::ConstIterator::name () const{    return *_i->first;}inline const Attribute &	Header::ConstIterator::attribute () const{    return *_i->second;}inline booloperator == (const Header::ConstIterator &x, const Header::ConstIterator &y){    return x._i == y._i;}inline booloperator != (const Header::ConstIterator &x, const Header::ConstIterator &y){    return !(x == y);}//---------------------// Template definitions//---------------------template <class T>T &Header::typedAttribute (const char name[]){    Attribute *attr = &(*this)[name];    T *tattr = dynamic_cast <T*> (attr);    if (tattr == 0)	throw Iex::TypeExc ("Unexpected attribute type.");    return *tattr;}template <class T>const T &Header::typedAttribute (const char name[]) const{    const Attribute *attr = &(*this)[name];    const T *tattr = dynamic_cast <const T*> (attr);    if (tattr == 0)	throw Iex::TypeExc ("Unexpected attribute type.");    return *tattr;}template <class T>T *Header::findTypedAttribute (const char name[]){    AttributeMap::iterator i = _map.find (name);    return (i == _map.end())? 0: dynamic_cast <T*> (i->second);}template <class T>const T *Header::findTypedAttribute (const char name[]) const{    AttributeMap::const_iterator i = _map.find (name);    return (i == _map.end())? 0: dynamic_cast <const T*> (i->second);}} // namespace Imf#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -