1 | Index: glsingleview.cpp
|
---|
2 | ===================================================================
|
---|
3 | --- glsingleview.cpp (revision 9409)
|
---|
4 | +++ glsingleview.cpp (working copy)
|
---|
5 | @@ -35,6 +35,7 @@
|
---|
6 |
|
---|
7 | #include "glsingleview.h"
|
---|
8 | #include "galleryutil.h"
|
---|
9 | +#include "config.h"
|
---|
10 |
|
---|
11 | GLSDialog::GLSDialog(const ThumbList& itemList, int pos, int slideShow,
|
---|
12 | MythMainWindow *parent, const char *name)
|
---|
13 | @@ -143,6 +144,11 @@
|
---|
14 | m_texInfo = 0;
|
---|
15 | m_showInfo = false;
|
---|
16 | m_sequence = 0;
|
---|
17 | +#ifdef EXIF_SUPPORT
|
---|
18 | + m_showDate = gContext->GetNumSetting("SlideshowShowDate");
|
---|
19 | + m_texDate = 0;
|
---|
20 | +#endif
|
---|
21 | + // ---------------------------------------------------------------
|
---|
22 |
|
---|
23 | // ---------------------------------------------------------------
|
---|
24 |
|
---|
25 | @@ -184,6 +190,10 @@
|
---|
26 | glDeleteTextures(1, &m_texItem[0].tex);
|
---|
27 | if (m_texItem[1].tex)
|
---|
28 | glDeleteTextures(1, &m_texItem[1].tex);
|
---|
29 | +#ifdef EXIF_SUPPORT
|
---|
30 | +// if (m_texDate)
|
---|
31 | + // glDeleteTextures(1, &m_texDate);
|
---|
32 | +#endif
|
---|
33 | }
|
---|
34 |
|
---|
35 | void GLSingleView::initializeGL()
|
---|
36 | @@ -480,7 +490,6 @@
|
---|
37 | glEnd();
|
---|
38 |
|
---|
39 | if (m_showInfo) {
|
---|
40 | -
|
---|
41 | createTexInfo();
|
---|
42 |
|
---|
43 | glMatrixMode(GL_MODELVIEW);
|
---|
44 | @@ -508,7 +517,34 @@
|
---|
45 | glEnd();
|
---|
46 |
|
---|
47 | }
|
---|
48 | +#ifdef EXIF_SUPPORT
|
---|
49 | + if (m_showDate) {
|
---|
50 | + createDateInfo(date);
|
---|
51 | + glMatrixMode(GL_MODELVIEW);
|
---|
52 | + glLoadIdentity();
|
---|
53 |
|
---|
54 | + glMatrixMode(GL_TEXTURE);
|
---|
55 | + glLoadIdentity();
|
---|
56 | +
|
---|
57 | + glBindTexture(GL_TEXTURE_2D, m_texDate);
|
---|
58 | + glBegin(GL_QUADS);
|
---|
59 | + {
|
---|
60 | + glColor4f(1.0, 1.0, 1.0, 0.5);
|
---|
61 | + glTexCoord2f(0, 0);
|
---|
62 | + glVertex3f(0.3, -1, 0);
|
---|
63 | +
|
---|
64 | + glTexCoord2f(1, 0);
|
---|
65 | + glVertex3f(1, -1, 0);
|
---|
66 | +
|
---|
67 | + glTexCoord2f(1, 1);
|
---|
68 | + glVertex3f(1, -0.8, 0);
|
---|
69 | +
|
---|
70 | + glTexCoord2f(0, 1);
|
---|
71 | + glVertex3f(0.3, -0.8, 0);
|
---|
72 | + }
|
---|
73 | + glEnd();
|
---|
74 | + }
|
---|
75 | +#endif
|
---|
76 | }
|
---|
77 |
|
---|
78 | void GLSingleView::advanceFrame()
|
---|
79 | @@ -616,6 +652,10 @@
|
---|
80 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
|
---|
81 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
|
---|
82 |
|
---|
83 | +#ifdef EXIF_SUPPORT
|
---|
84 | + date = GalleryUtil::getDate(item->path);
|
---|
85 | +#endif
|
---|
86 | +
|
---|
87 | }
|
---|
88 | }
|
---|
89 |
|
---|
90 | @@ -1545,3 +1585,35 @@
|
---|
91 | glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
|
---|
92 | }
|
---|
93 |
|
---|
94 | +#ifdef EXIF_SUPPORT
|
---|
95 | +void GLSingleView::createDateInfo(QString value)
|
---|
96 | +{
|
---|
97 | + if (m_texDate)
|
---|
98 | + glDeleteTextures(1, &m_texDate);
|
---|
99 | +
|
---|
100 | + QPixmap pix(256, 32);
|
---|
101 | +
|
---|
102 | + QPainter p(&pix, this);
|
---|
103 | + p.fillRect(0,0,pix.width(),pix.height(),Qt::black);
|
---|
104 | + p.setPen(Qt::white);
|
---|
105 | +
|
---|
106 | + p.drawText(5, 5, pix.width()-5, pix.height()-5,
|
---|
107 | + Qt::AlignLeft, value);
|
---|
108 | + p.end();
|
---|
109 | +
|
---|
110 | + QImage img(pix.convertToImage());
|
---|
111 | + img = img.convertDepth(32);
|
---|
112 | +
|
---|
113 | + QImage tex = convertToGLFormat(img);
|
---|
114 | +
|
---|
115 | + /* create the texture */
|
---|
116 | + glGenTextures(1, &m_texDate);
|
---|
117 | + glBindTexture(GL_TEXTURE_2D, m_texDate);
|
---|
118 | + /* actually generate the texture */
|
---|
119 | + glTexImage2D( GL_TEXTURE_2D, 0, 3, tex.width(), tex.height(), 0,
|
---|
120 | + GL_RGBA, GL_UNSIGNED_BYTE, tex.bits() );
|
---|
121 | + /* enable linear filtering */
|
---|
122 | + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
|
---|
123 | + glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
|
---|
124 | +}
|
---|
125 | +#endif
|
---|
126 | Index: galleryutil.h
|
---|
127 | ===================================================================
|
---|
128 | --- galleryutil.h (revision 9409)
|
---|
129 | +++ galleryutil.h (working copy)
|
---|
130 | @@ -28,7 +28,7 @@
|
---|
131 | static bool isImage(const char* filePath);
|
---|
132 | static bool isMovie(const char* filePath);
|
---|
133 | static long getNaturalRotation(const char* filePath);
|
---|
134 | -
|
---|
135 | + static QString getDate(const char* filePath);
|
---|
136 | static QString getCaption(const QString &filePath);
|
---|
137 |
|
---|
138 | static bool loadDirectory(ThumbList& itemList,
|
---|
139 | Index: glsingleview.h
|
---|
140 | ===================================================================
|
---|
141 | --- glsingleview.h (revision 9409)
|
---|
142 | +++ glsingleview.h (working copy)
|
---|
143 | @@ -26,6 +26,7 @@
|
---|
144 | #include <qmap.h>
|
---|
145 |
|
---|
146 | #include "iconview.h"
|
---|
147 | +#include "config.h"
|
---|
148 | #include "sequence.h"
|
---|
149 |
|
---|
150 | class QImage;
|
---|
151 | @@ -99,6 +100,11 @@
|
---|
152 | bool m_effectRunning;
|
---|
153 | bool m_running;
|
---|
154 | int m_slideShow;
|
---|
155 | +#ifdef EXIF_SUPPORT
|
---|
156 | + int m_showDate;
|
---|
157 | + GLuint m_texDate;
|
---|
158 | + QString date;
|
---|
159 | +#endif
|
---|
160 |
|
---|
161 | GLuint m_texInfo;
|
---|
162 | bool m_showInfo;
|
---|
163 | @@ -121,7 +127,9 @@
|
---|
164 | void paintTexture();
|
---|
165 | void rotate(int angle);
|
---|
166 | void createTexInfo();
|
---|
167 | -
|
---|
168 | +#ifdef EXIF_SUPPORT
|
---|
169 | + void createDateInfo(QString);
|
---|
170 | +#endif
|
---|
171 | void registerEffects();
|
---|
172 | EffectMethod getRandomEffect();
|
---|
173 |
|
---|
174 | Index: gallerysettings.cpp
|
---|
175 | ===================================================================
|
---|
176 | --- gallerysettings.cpp (revision 9409)
|
---|
177 | +++ gallerysettings.cpp (working copy)
|
---|
178 | @@ -72,6 +72,18 @@
|
---|
179 | return gc;
|
---|
180 | };
|
---|
181 |
|
---|
182 | +#ifdef EXIF_SUPPORT
|
---|
183 | +static HostCheckBox *SlideshowShowDate()
|
---|
184 | +{
|
---|
185 | + HostCheckBox *gc = new HostCheckBox("SlideshowShowDate");
|
---|
186 | + gc->setLabel(QObject::tr("Show Photo date on image"));
|
---|
187 | + gc->setHelpText(QObject::tr("Check this to show the date/time "
|
---|
188 | + "that the photo was taken on the image"));
|
---|
189 | + return gc;
|
---|
190 | +};
|
---|
191 | +#endif
|
---|
192 | +
|
---|
193 | +
|
---|
194 | static HostComboBox *SlideshowOpenGLTransition()
|
---|
195 | {
|
---|
196 | HostComboBox *gc = new HostComboBox("SlideshowOpenGLTransition");
|
---|
197 | @@ -165,7 +177,7 @@
|
---|
198 | addChild(MythGalleryMoviePlayerCmd());
|
---|
199 |
|
---|
200 | #ifdef OPENGL_SUPPORT
|
---|
201 | -
|
---|
202 | +
|
---|
203 | HostCheckBox* useOpenGL = SlideshowUseOpenGL();
|
---|
204 | addChild(useOpenGL);
|
---|
205 | setTrigger(useOpenGL);
|
---|
206 | @@ -179,6 +191,11 @@
|
---|
207 | regularConfig->addChild(SlideshowBackground());
|
---|
208 | addTarget("0", regularConfig);
|
---|
209 |
|
---|
210 | +#ifdef EXIF_SUPPORT
|
---|
211 | + HostCheckBox* showDate = SlideshowShowDate();
|
---|
212 | + openGLConfig->addChild(showDate);
|
---|
213 | +#endif
|
---|
214 | +
|
---|
215 | #else
|
---|
216 | addChild(MythGalleryOverlayCaption());
|
---|
217 | addChild(SlideshowTransition());
|
---|
218 | Index: galleryutil.cpp
|
---|
219 | ===================================================================
|
---|
220 | --- galleryutil.cpp (revision 9409)
|
---|
221 | +++ galleryutil.cpp (working copy)
|
---|
222 | @@ -263,3 +263,47 @@
|
---|
223 |
|
---|
224 | return caption;
|
---|
225 | }
|
---|
226 | +
|
---|
227 | +QString GalleryUtil::getDate(const char* filePath)
|
---|
228 | +{
|
---|
229 | + QString date;
|
---|
230 | + try
|
---|
231 | + {
|
---|
232 | +#ifdef EXIF_SUPPORT
|
---|
233 | + char *exifvalue = new char[1024];
|
---|
234 | + ExifData *data = exif_data_new_from_file (filePath);
|
---|
235 | + if (data)
|
---|
236 | + {
|
---|
237 | + for (int i = 0; i < EXIF_IFD_COUNT; i++)
|
---|
238 | + {
|
---|
239 | + ExifEntry *entry = exif_content_get_entry (data->ifd[i],
|
---|
240 | + EXIF_TAG_DATE_TIME);
|
---|
241 | + if (entry)
|
---|
242 | + {
|
---|
243 | +#if NEW_LIB_EXIF
|
---|
244 | + exif_entry_get_value(entry, exifvalue, 1023);
|
---|
245 | + date = exifvalue;
|
---|
246 | +#else
|
---|
247 | + date = exif_entry_get_value(entry);
|
---|
248 | +#endif
|
---|
249 | + break;
|
---|
250 | + }
|
---|
251 | + }
|
---|
252 | + exif_data_free(data);
|
---|
253 | + }
|
---|
254 | + else
|
---|
255 | + {
|
---|
256 | + std::cerr << "Could not load exif data from " << filePath << std::endl;
|
---|
257 | + }
|
---|
258 | +
|
---|
259 | + delete [] exifvalue;
|
---|
260 | +
|
---|
261 | +#endif // EXIF_SUPPORT
|
---|
262 | + }
|
---|
263 | + catch (...)
|
---|
264 | + {
|
---|
265 | + std::cerr << "GalleryUtil: Failed to extract EXIF headers from "
|
---|
266 | + << filePath << std::endl;
|
---|
267 | + }
|
---|
268 | + return date;
|
---|
269 | +}
|
---|