Proper check for rawzor libraries.
[rawtherapee-fixes.git] / rtgui / thumbnail.h
blob389e8e87293d1942a11bb46bdec8eb0a54b87327
1 /*
2 * This file is part of RawTherapee.
4 * Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
6 * RawTherapee is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * RawTherapee is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef _THUMBNAIL_
20 #define _THUMBNAIL_
22 #include <string>
23 #include <glibmm.h>
24 #include <cachemanager.h>
25 #include <options.h>
26 #include <rtengine.h>
27 #include <rtthumbnail.h>
28 #include <cacheimagedata.h>
29 #include <thumbnaillistener.h>
31 class CacheManager;
32 class Thumbnail {
34 Glib::Mutex* mutex;
36 Glib::ustring fname; // file name corresponding to the thumbnail
37 CacheImageData cfs; // cache entry corresponding to the thumbnail
38 CacheManager* cachemgr; // parent
39 int ref; // variable for reference counting
40 int enqueueNumber; // the number of instances in the batch queue corresponding to this thumbnail
42 // if the thumbnail is in processed mode, this class holds its data:
43 rtengine::Thumbnail* tpp;
44 int tw, th; // dimensions of timgdata (it stores tpp->width and tpp->height in processed mode for simplicity)
45 // double scale; // portion of the sizes of the processed thumbnail image and the full scale image
47 rtengine::procparams::ProcParams pparams;
48 bool pparamsValid;
49 bool pparamsSet;
50 bool needsReProcessing;
52 // these are the data of the result image of the last getthumbnailimage call (for caching purposes)
53 unsigned char* lastImg;
54 int lastW;
55 int lastH;
57 // exif & date/time strings
58 Glib::ustring exifString;
59 Glib::ustring dateTimeString;
61 // vector of listeners
62 std::vector<ThumbnailListener*> listeners;
64 void infoFromImage (const Glib::ustring& fname, rtengine::RawMetaDataLocation* rml=NULL);
65 void loadThumbnail (bool internal=false, bool firstTrial=true);
66 void saveThumbnail ();
67 void generateExifDateTimeStrings ();
69 Glib::ustring getCacheFileName (Glib::ustring subdir);
71 public:
72 Thumbnail (CacheManager* cm, const Glib::ustring& fname, CacheImageData* cf);
73 Thumbnail (CacheManager* cm, const Glib::ustring& fname, const std::string& md5);
74 ~Thumbnail ();
76 bool hasProcParams ();
77 const rtengine::procparams::ProcParams& getProcParams ();
78 void setProcParams (const rtengine::procparams::ProcParams& pp, int whoChangedIt=-1, bool updateCacheNow=true);
79 void clearProcParams (int whoClearedIt=-1);
80 void loadProcParams ();
82 bool isRecentlySaved ();
83 void imageDeveloped ();
84 void imageEnqueued ();
85 void imageRemovedFromQueue ();
86 bool isEnqueued ();
88 // unsigned char* getThumbnailImage (int &w, int &h, int fixwh=1); // fixwh = 0: fix w and calculate h, =1: fix h and calculate w
89 rtengine::IImage8* processThumbImage (const rtengine::procparams::ProcParams& pparams, int h, double& scale);
90 void processThumbImage2 (const rtengine::procparams::ProcParams& pparams, int h, rtengine::IImage8*& img, double& scale) { img = processThumbImage(pparams, h, scale); }
91 void getThumbnailSize (int &w, int &h);
92 void getFinalSize (const rtengine::procparams::ProcParams& pparams, int& w, int& h) { if (tpp) tpp->getFinalSize (pparams, w, h); }
94 void generateThumbnailImage (bool internal=false);
96 const Glib::ustring& getExifString ();
97 const Glib::ustring& getDateTimeString ();
98 void getCamWB (double& temp, double& green) { if (tpp) tpp->getCamWB (temp, green); }
99 void getAutoWB (double& temp, double& green) { if (tpp) tpp->getAutoWB (temp, green); }
100 void getSpotWB (int x, int y, int rect, double& temp, double& green) { if (tpp) tpp->getSpotWB (getProcParams(), x, y, rect, temp, green); }
101 void applyAutoExp (rtengine::procparams::ProcParams& pparams) { if (tpp) tpp->applyAutoExp (pparams); }
103 ThFileType getType ();
104 Glib::ustring getFileName () { return fname; }
105 void setFileName (const Glib::ustring fn);
107 bool isSupported ();
109 const CacheImageData* getCacheImageData() { return &cfs; }
110 std::string getMD5 () { return cfs.md5; }
112 int getRank () { return cfs.rank; }
113 void setRank (int rank) { cfs.rank = rank; }
115 int getStage () { return cfs.inTrash; }
116 void setStage (int stage) { cfs.inTrash = stage; }
118 void addThumbnailListener (ThumbnailListener* tnl);
119 void removeThumbnailListener (ThumbnailListener* tnl);
121 void increaseRef ();
122 void decreaseRef ();
124 void updateCache ();
125 void reSaveThumbnail () { mutex->lock (); saveThumbnail(); mutex->unlock(); }
129 #endif