/* * borrowed from vdrplugin-text2skin */ #ifndef VDR_PICSELSHOW_BITMAP_H #define VDR_PICSELSHOW_BITMAP_H //#include //#include "common.h" #include "imagecache.h" #include struct tImageSpec { std::string Filename; int Width; int Height; bool Ratio; tImageSpec(const std::string &filename, int width, int height, bool ratio): Filename(filename), Width(width), Height(height), Ratio(ratio) {} bool operator<(const tImageSpec &Src) const; bool operator==(const tImageSpec &Src) const; }; inline bool tImageSpec::operator<(const tImageSpec &Src) const { if (Filename == Src.Filename) { if (Width == Src.Width) { if (Height == Src.Height) return Ratio < Src.Ratio; return Height < Src.Height; } return Width < Src.Width; } return Filename < Src.Filename; } inline bool tImageSpec::operator==(const tImageSpec &Src) const { return Filename == Src.Filename && Width == Src.Width && Height == Src.Height && Ratio == Src.Ratio; } class cImageloadBitmap; class cImageCache: public cxCache { protected: virtual void DeleteObject(const tImageSpec &Key, cImageloadBitmap *&Data); virtual void ResetObject(cImageloadBitmap *&Data); public: cImageCache(uint MaxItems): cxCache(MaxItems) {} virtual ~cImageCache() { Flush(); } }; class cImageloadBitmap { private: static cImageCache mCache; std::vector mBitmaps; int mCurrent; int newheight; int newwidth; // disallow direct construction cImageloadBitmap(void); bool LoadImage(const char *Filename, int width, int height, bool ratio, int rotate); public: static cImageloadBitmap *Load(const std::string &Filename, int width = 0, int height = 0, bool ratio = false, int rotate = 0); static bool Available(const std::string &Filename, int width = 0, int height = 0, bool ratio = false, int rotate = 0); static void ResetCache(void) { mCache.Reset(); } static void FlushCache(void) { mCache.Flush(); } static void Init(void); virtual ~cImageloadBitmap(); int newHeight(void) {return newheight;} int newWidth(void) {return newwidth;} void Reset(void) { mCurrent = 0; } cImage &Get(void); }; #endif // VDR_PICSELSHOW_BITMAP_H