24 #ifndef _HUGINAPP_IMAGECACHE_H
25 #define _HUGINAPP_IMAGECACHE_H
28 #include "hugin_config.h"
33 #include <vigra/stdimage.hxx>
34 #include <vigra/imageinfo.hxx>
38 #define HUGIN_IMGCACHE_MAPPING_INTEGER 0l
39 #define HUGIN_IMGCACHE_MAPPING_FLOAT 1l
85 DEBUG_TRACE(
"Constructing an empty ImageCache::Entry");
94 const std::string & typ)
95 : image8(img), image16(img16), imageFloat(imgFloat), mask(imgMask),
96 iccProfile(ICCProfile), origType(typ), lastAccess(0)
120 Request(std::string filename,
bool request_small)
121 :m_filename(filename), m_isSmall(request_small)
131 std::vector <std::function<void(EntryPtr, std::string, bool)>> ready;
135 {
return m_filename;};
137 std::string m_filename;
156 : asyncLoadCompleteSignal(0), upperBound(100*1024*1024ull),
157 m_progress(NULL), m_accessCounter(0)
188 EntryPtr getImage(
const std::string & filename);
197 EntryPtr getImageIfAvailable(
const std::string & filename);
208 EntryPtr getSmallImage(
const std::string & filename);
219 EntryPtr getSmallImageIfAvailable(
const std::string & filename);
227 RequestPtr requestAsyncImage(
const std::string & filename);
235 RequestPtr requestAsyncSmallImage(
const std::string & filename);
240 void removeImage(
const std::string & filename);
256 void SetUpperLimit(
const unsigned long long newUpperLimit) { upperBound=newUpperLimit; };
289 template <
class SrcPixelType,
290 class DestIterator,
class DestAccessor>
291 static void importAndConvertImage(
const vigra::ImageImportInfo&
info,
292 vigra::pair<DestIterator, DestAccessor> dest,
293 const std::string& type);
307 template <
class SrcPixelType,
308 class DestIterator,
class DestAccessor,
309 class MaskIterator,
class MaskAccessor>
310 static void importAndConvertAlphaImage(
const vigra::ImageImportInfo &
info,
311 vigra::pair<DestIterator, DestAccessor> dest,
312 vigra::pair<MaskIterator, MaskAccessor> mask,
313 const std::string & type);
319 { m_progress = disp; }
323 { m_progress = NULL; }
341 void spawnAsyncThread();
356 static EntryPtr loadImageSafely(
const std::string & filename);
390 : filename(str), level(lv)
393 std::string toString();
401 #endif // _IMAGECACHE_H
void clearProgressDisplay(AppBase::ProgressDisplay *disp)
ImageCacheICCProfile iccProfile
AppBase::ProgressDisplay * m_progress
Request for an image to load Connect to the ready signal so when the image loads you can respond...
std::shared_ptr< vigra::FRGBImage > ImageCacheRGBFloatPtr
unsigned long long upperBound
std::shared_ptr< vigra::ImageImportInfo::ICCProfile > ImageCacheICCProfile
This is a cache for all the images we use.
std::map< std::string, RequestPtr > m_smallRequests
information about an image inside the cache
std::shared_ptr< vigra::BImage > ImageCache8Ptr
virtual ~ImageCache()
dtor.
const std::string & getFilename() const
std::shared_ptr< Entry > EntryPtr
a shared pointer to the entry
std::shared_ptr< vigra::BRGBImage > ImageCacheRGB8Ptr
use reference counted pointers
ImageCacheRGB16Ptr image16
std::map< std::string, RequestPtr > m_requests
std::shared_ptr< Request > RequestPtr
Reference counted request for an image to load.
static ImageCache * instance
ImageCacheRGBFloatPtr imageFloat
std::map< std::string, EntryPtr > images
PyramidKey(const std::string &str, int lv)
void setProgressDisplay(AppBase::ProgressDisplay *disp)
Entry(ImageCacheRGB8Ptr &img, ImageCacheRGB16Ptr &img16, ImageCacheRGBFloatPtr &imgFloat, ImageCache8Ptr &imgMask, ImageCacheICCProfile &ICCProfile, const std::string &typ)
void SetUpperLimit(const unsigned long long newUpperLimit)
sets the upper limit, which is used by softFlush()
std::map< std::string, vigra::BImage * > pyrImages
Request(std::string filename, bool request_small)
static void info(const char *fmt,...)
std::shared_ptr< vigra::UInt16RGBImage > ImageCacheRGB16Ptr