2 * $Id: pictureviewer.cpp,v 1.46 2008/01/19 16:46:53 dbluelle Exp $
4 * (C) 2005 by digi_casi <digi_casi@tuxbox.org>
6 * This program 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 2 of the License, or
9 * (at your option) any later version.
11 * This program 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 this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <lib/driver/streamwd.h>
24 #include <lib/system/info.h>
25 #include <lib/system/init.h>
26 #include <lib/system/init_num.h>
27 #include <lib/system/econfig.h>
28 #include <lib/gdi/fb.h>
29 #include <lib/base/estring.h>
30 #include <lib/gui/actions.h>
31 #include <lib/gui/guiactions.h>
32 #include <lib/dvb/servicedvb.h>
33 #include <sys/types.h>
40 #include <src/enigma_main.h>
41 #include <lib/gui/eskin.h>
42 #include <lib/gui/elabel.h>
43 #include <lib/gdi/font.h>
44 #include <lib/picviewer/pictureviewer.h>
45 #include "fb_display.h"
46 #include <lib/picviewer/format_config.h>
47 #include <lib/driver/eavswitch.h>
50 extern unsigned char *simple_resize(unsigned char *orgin
, int ox
, int oy
, int dx
, int dy
);
51 extern unsigned char *color_average_resize(unsigned char *orgin
, int ox
, int oy
, int dx
, int dy
);
53 #ifdef FBV_SUPPORT_GIF
54 extern int fh_gif_getsize(const char *, int *, int *, int, int);
55 extern int fh_gif_load(const char *, unsigned char *, int, int);
56 extern int fh_gif_id(const char *);
58 #ifdef FBV_SUPPORT_JPEG
59 extern int fh_jpeg_getsize(const char *, int *, int *, int, int);
60 extern int fh_jpeg_load(const char *, unsigned char *, int, int);
61 extern int fh_jpeg_id(const char *);
63 #ifdef FBV_SUPPORT_PNG
64 extern int fh_png_getsize(const char *, int *, int *, int, int);
65 extern int fh_png_load(const char *, unsigned char *, int, int);
66 extern int fh_png_id(const char *);
68 #ifdef FBV_SUPPORT_BMP
69 extern int fh_bmp_getsize(const char *, int *, int *, int, int);
70 extern int fh_bmp_load(const char *, unsigned char *, int, int);
71 extern int fh_bmp_id(const char *);
73 #ifdef FBV_SUPPORT_CRW
74 extern int fh_crw_getsize(const char *, int *, int *, int, int);
75 extern int fh_crw_load(const char *, unsigned char *, int, int);
76 extern int fh_crw_id(const char *);
79 void ePictureViewer::nextPicture()
81 if (++myIt
== slideshowList
.end())
82 myIt
= slideshowList
.begin();
85 void ePictureViewer::previousPicture()
87 if (myIt
== slideshowList
.begin())
89 myIt
= slideshowList
.end();
96 void ePictureViewer::showNameOnLCD(const eString
& filename
)
98 unsigned int pos
= filename
.find_last_of("/");
99 pos
= (pos
== eString::npos
) ? 0 : pos
+ 1;
100 eString name
= filename
.substr(pos
, filename
.length() - 1);
102 pLCD
->lcdMain
->ServiceName
->setText(name
);
103 pLCD
->lcdMain
->show();
107 ePictureViewer::ePictureViewer(const eString
&filename
)
108 :eWidget(0, 1), slideshowTimer(eApp
), filename(filename
)
110 // eDebug("[PICTUREVIEWER] Constructor...");
112 addActionMap(&i_cursorActions
->map
);
113 addActionMap(&i_shortcutActions
->map
);
114 addActionToHelpList(i_shortcutActions
->blue
.setDescription(_("display next picture")));
115 addActionToHelpList(i_shortcutActions
->red
.setDescription(_("display previous picture")));
116 addActionToHelpList(i_shortcutActions
->green
.setDescription(_("start slideshow")));
117 addActionToHelpList(i_shortcutActions
->yellow
.setDescription(_("stop slideshow")));
118 addActionToHelpList(i_shortcutActions
->number0
.setDescription(_("toggle fit to screen width/fit to screen")));
119 addActionToHelpList(i_shortcutActions
->number1
.setDescription(_("zoom out")));
120 addActionToHelpList(i_shortcutActions
->number3
.setDescription(_("zoom in")));
121 addActionToHelpList(i_shortcutActions
->number5
.setDescription(_("toggle 16/9 mode")));
122 addActionToHelpList(i_shortcutActions
->number2
.setDescription(_("move picture up")));
123 addActionToHelpList(i_shortcutActions
->number4
.setDescription(_("move picture left")));
124 addActionToHelpList(i_shortcutActions
->number6
.setDescription(_("move picture right")));
125 addActionToHelpList(i_shortcutActions
->number8
.setDescription(_("move picture down")));
127 move(ePoint(70, 50));
128 resize(eSize(590, 470));
129 eLabel
*l
= new eLabel(this);
130 l
->move(ePoint(150, clientrect
.height() / 2));
131 l
->setFont(eSkin::getActive()->queryFont("epg.title"));
132 l
->resize(eSize(clientrect
.width() - 100, 30));
133 l
->setText(_("Loading slide... please wait."));
136 pLCD
= eZapLCD::getInstance();
143 m_NextPic_Buffer
= NULL
;
150 m_bFitScreen
= false;
152 m_startx
= 20, m_starty
= 20, m_endx
= 699, m_endy
= 555;
153 eConfig::getInstance()->getKey("/enigma/plugins/needoffsets/left", m_startx
); // left
154 eConfig::getInstance()->getKey("/enigma/plugins/needoffsets/top", m_starty
); // top
155 eConfig::getInstance()->getKey("/enigma/plugins/needoffsets/right", m_endx
); // right
156 eConfig::getInstance()->getKey("/enigma/plugins/needoffsets/bottom", m_endy
); // bottom
158 int showbusysign
= 1;
159 eConfig::getInstance()->getKey("/picviewer/showbusysign", showbusysign
);
160 showBusySign
= (showbusysign
== 1);
161 unsigned int v_pin8
= 0;
162 eConfig::getInstance()->getKey("/elitedvb/video/pin8", v_pin8
);
164 if ((v_pin8
== 3) || // always 16:9
165 ((v_pin8
> 1) && (eServiceInterface::getInstance()->getService()->getAspectRatio() == 1)))
176 eConfig::getInstance()->getKey("/picviewer/format169", format169
);
179 eAVSwitch::getInstance()->setAspectRatio(r169
);
182 m_busy_buffer
= NULL
;
186 CONNECT(slideshowTimer
.timeout
, ePictureViewer::slideshowTimeout
);
187 // eDebug("[PICTUREVIEWER] Constructor done.");
190 ePictureViewer::~ePictureViewer()
192 if (m_busy_buffer
!= NULL
)
194 delete [] m_busy_buffer
;
195 m_busy_buffer
= NULL
;
197 if (m_NextPic_Buffer
!= NULL
)
199 delete [] m_NextPic_Buffer
;
200 m_NextPic_Buffer
= NULL
;
203 CFormathandler
*tmp
= NULL
;
207 fh_root
= fh_root
->next
;
210 // restore original screen size
211 eStreamWatchdog::getInstance()->reloadSettings();
214 void ePictureViewer::add_format(int (*picsize
)(const char *, int *, int *, int, int ), int (*picread
)(const char *, unsigned char *, int, int), int (*id
)(const char*))
217 fhn
= new CFormathandler
;
218 fhn
->get_size
= picsize
;
219 fhn
->get_pic
= picread
;
225 void ePictureViewer::init_handlers(void)
227 #ifdef FBV_SUPPORT_GIF
228 add_format(fh_gif_getsize
, fh_gif_load
, fh_gif_id
);
230 #ifdef FBV_SUPPORT_JPEG
231 add_format(fh_jpeg_getsize
, fh_jpeg_load
, fh_jpeg_id
);
233 #ifdef FBV_SUPPORT_PNG
234 add_format(fh_png_getsize
, fh_png_load
, fh_png_id
);
236 #ifdef FBV_SUPPORT_BMP
237 add_format(fh_bmp_getsize
, fh_bmp_load
, fh_bmp_id
);
239 #ifdef FBV_SUPPORT_CRW
240 add_format(fh_crw_getsize
, fh_crw_load
, fh_crw_id
);
244 ePictureViewer::CFormathandler
*ePictureViewer::fh_getsize(const char *name
, int *x
, int *y
, int width_wanted
, int height_wanted
)
247 for (fh
= fh_root
; fh
!= NULL
; fh
= fh
->next
)
249 if (fh
->id_pic(name
))
250 if (fh
->get_size(name
, x
, y
, width_wanted
, height_wanted
) == FH_ERROR_OK
)
256 bool ePictureViewer::DecodeImage(const std::string
& name
, bool unscaled
)
258 // eDebug("DecodeImage {");
260 int x
, y
, xs
, ys
, imx
, imy
;
261 getCurrentRes(&xs
, &ys
);
263 // Show red block for "next ready" in view state
265 showBusy(m_startx
+ 3, m_starty
+ 3, 10, 0xff, 0, 0);
268 if (unscaled
|| m_bFitScreen
)
269 fh
= fh_getsize(name
.c_str(), &x
, &y
, m_endx
- m_startx
, INT_MAX
);
271 fh
= fh_getsize(name
.c_str(), &x
, &y
, m_endx
- m_startx
, m_endy
- m_starty
);
274 if (m_NextPic_Buffer
!= NULL
)
276 delete [] m_NextPic_Buffer
;
278 m_NextPic_Buffer
= new unsigned char[x
* y
* 3];
279 if (m_NextPic_Buffer
== NULL
)
281 eDebug("Error: malloc");
285 // eDebug("---Decoding start(%d/%d)", x, y);
286 if (fh
->get_pic(name
.c_str(), m_NextPic_Buffer
, x
, y
) == FH_ERROR_OK
)
288 // eDebug("---Decoding done");
289 if (m_bFitScreen
|| (((x
> (m_endx
- m_startx
)) || y
> (m_endy
- m_starty
)) && m_scaling
!= NONE
&& !unscaled
))
291 double aspect_ratio_correction
= m_aspect
/ ((double)xs
/ ys
);
292 if (m_bFitScreen
|| (aspect_ratio_correction
* y
* (m_endx
- m_startx
) / x
) <= (m_endy
- m_starty
))
294 imx
= (m_endx
- m_startx
);
295 imy
= (int)(aspect_ratio_correction
* y
* (m_endx
- m_startx
) / x
);
299 imx
= (int)((1.0 / aspect_ratio_correction
) * x
* (m_endy
- m_starty
) / y
);
300 imy
= m_endy
- m_starty
;
302 if (m_scaling
== SIMPLE
)
303 m_NextPic_Buffer
= simple_resize(m_NextPic_Buffer
, x
, y
, imx
, imy
);
305 m_NextPic_Buffer
= color_average_resize(m_NextPic_Buffer
, x
, y
, imx
, imy
);
312 m_NextPic_XPos
= m_startx
;
313 m_NextPic_YPos
= m_starty
;
319 if (x
< (m_endx
- m_startx
))
320 m_NextPic_XPos
= (m_endx
- m_startx
- x
) / 2 + m_startx
;
322 m_NextPic_XPos
= m_startx
;
323 if (y
< (m_endy
- m_starty
))
324 m_NextPic_YPos
= (m_endy
- m_starty
-y
) / 2 + m_starty
;
326 m_NextPic_YPos
= m_starty
;
327 if (x
> (m_endx
- m_startx
))
328 m_NextPic_XPan
= (x
- (m_endx
- m_startx
)) / 2;
331 if (y
> (m_endy
- m_starty
))
332 m_NextPic_YPan
= (y
- (m_endy
- m_starty
)) / 2;
339 // eDebug("Unable to read file !");
340 delete [] m_NextPic_Buffer
;
341 m_NextPic_Buffer
= new unsigned char[3];
342 if (m_NextPic_Buffer
== NULL
)
344 eDebug("Error: malloc");
347 memset(m_NextPic_Buffer
, 0 , 3);
358 // eDebug("Unable to read file or format not recognized!");
359 if (m_NextPic_Buffer
!= NULL
)
361 delete [] m_NextPic_Buffer
;
363 m_NextPic_Buffer
= new unsigned char[3];
364 if (m_NextPic_Buffer
== NULL
)
366 eDebug("Error: malloc");
369 memset(m_NextPic_Buffer
, 0 , 3);
377 m_NextPic_Name
= name
;
379 // eDebug("DecodeImage }");
380 return(m_NextPic_Buffer
!= NULL
);
383 bool ePictureViewer::ShowImage(const std::string
& filename
, bool unscaled
)
385 // eDebug("Show Image {");
386 unsigned int pos
= filename
.find_last_of("/");
387 if (pos
== eString::npos
)
388 pos
= filename
.length() - 1;
389 eString directory
= pos
? filename
.substr(0, pos
) : "";
390 // eDebug("---directory: %s", directory.c_str());
391 slideshowList
.clear();
392 int includesubdirs
= 0;
393 eConfig::getInstance()->getKey("/picviewer/includesubdirs", includesubdirs
);
394 listDirectory(directory
, includesubdirs
);
395 for (myIt
= slideshowList
.begin(); myIt
!= slideshowList
.end(); myIt
++)
398 // eDebug("[PICTUREVIEWER] comparing: %s:%s", tmp.c_str(), filename.c_str());
402 DecodeImage(filename
, unscaled
);
403 struct fb_var_screeninfo
*screenInfo
= fbClass::getInstance()->getScreenInfo();
404 if (screenInfo
->bits_per_pixel
!= 16)
406 fbClass::getInstance()->lock();
407 fbClass::getInstance()->SetMode(720, 576, 16);
408 #if HAVE_DVB_API_VERSION == 3
409 fbClass::getInstance()->setTransparency(0);
413 pLCD
->lcdMenu
->hide();
415 showNameOnLCD(filename
);
417 // eDebug("Show Image }");
421 void ePictureViewer::slideshowTimeout()
424 // eDebug("[PICTUREVIEWER] slideshowTimeout: show %s", tmp.c_str());
425 DecodeImage(*myIt
, false);
430 eConfig::getInstance()->getKey("/picviewer/slideshowtimeout", timeout
);
431 slideshowTimer
.start(timeout
* 1000, true);
434 int ePictureViewer::eventHandler(const eWidgetEvent
&evt
)
436 static eString serviceName
;
440 case eWidgetEvent::evtAction
:
442 if (evt
.action
== &i_cursorActions
->cancel
)
445 if (evt
.action
== &i_cursorActions
->help
)
447 fbClass::getInstance()->SetMode(720, 576, 8);
448 fbClass::getInstance()->PutCMAP();
449 fbClass::getInstance()->unlock();
450 eWidget::eventHandler(evt
);
451 struct fb_var_screeninfo
*screenInfo
= fbClass::getInstance()->getScreenInfo();
452 if (screenInfo
->bits_per_pixel
!= 16)
454 fbClass::getInstance()->lock();
455 fbClass::getInstance()->SetMode(720, 576, 16);
456 #if HAVE_DVB_API_VERSION == 3
457 fbClass::getInstance()->setTransparency(0);
460 DecodeImage(*myIt
, false);
461 showNameOnLCD(*myIt
);
466 if (evt
.action
== &i_shortcutActions
->yellow
)
468 slideshowTimer
.stop();
471 if (evt
.action
== &i_shortcutActions
->green
)
477 if (evt
.action
== &i_shortcutActions
->number0
)
479 // Toggle FitToScreenWidth mode
480 m_bFitScreen
= !m_bFitScreen
;
481 DecodeImage(*myIt
, false);
485 if (evt
.action
== &i_shortcutActions
->number1
)
491 if (evt
.action
== &i_shortcutActions
->number2
)
496 if (evt
.action
== &i_shortcutActions
->number3
)
501 if (evt
.action
== &i_shortcutActions
->number4
)
506 if (evt
.action
== &i_shortcutActions
->number5
)
508 format169
= 1-format169
;
509 eConfig::getInstance()->setKey("/picviewer/format169", format169
);
513 eAVSwitch::getInstance()->setAspectRatio(r169
);
518 eAVSwitch::getInstance()->setAspectRatio(r43
);
522 if (evt
.action
== &i_shortcutActions
->number6
)
527 if (evt
.action
== &i_shortcutActions
->number8
)
532 if (evt
.action
== &i_cursorActions
->down
||
533 evt
.action
== &i_cursorActions
->right
||
534 evt
.action
== &i_shortcutActions
->blue
)
537 DecodeImage(*myIt
, false);
538 showNameOnLCD(*myIt
);
542 if (evt
.action
== &i_cursorActions
->up
||
543 evt
.action
== &i_cursorActions
->left
||
544 evt
.action
== &i_shortcutActions
->red
)
547 DecodeImage(*myIt
, false);
548 showNameOnLCD(*myIt
);
553 case eWidgetEvent::execBegin
:
556 serviceName
= pLCD
->lcdMain
->ServiceName
->getText();
558 ShowImage(filename
, false);
561 case eWidgetEvent::execDone
:
563 fbClass::getInstance()->SetMode(720, 576, 8);
564 fbClass::getInstance()->PutCMAP();
565 fbClass::getInstance()->unlock();
566 if (switchto43
&& format169
)
567 eAVSwitch::getInstance()->setAspectRatio(r43
);
568 showNameOnLCD(serviceName
);
570 pLCD
->lcdMain
->hide();
571 pLCD
->lcdMenu
->show();
576 return eWidget::eventHandler(evt
);
581 void ePictureViewer::listDirectory(eString directory
, int includesubdirs
)
583 // eDebug("[PICTUREVIEWER] listDirectory: dir %s", directory.c_str());
584 std::list
<eString
> piclist
;
585 std::list
<eString
>::iterator picIt
;
586 std::list
<eString
> dirlist
;
587 std::list
<eString
>::iterator dirIt
;
590 DIR *d
= opendir(directory
.c_str());
593 while (struct dirent
*e
= readdir(d
))
595 eString filename
= eString(e
->d_name
);
596 // eDebug("[PICTUREVIEWER] listDirectory: processing %s", filename.c_str());
597 if ((filename
!= ".") && (filename
!= ".."))
600 eString fullFilename
= directory
+ "/" + filename
;
601 if (lstat(fullFilename
.c_str(), &s
) < 0)
603 // eDebug("--- file no good :(");
607 if (S_ISREG(s
.st_mode
))
609 if (filename
.right(4).upper() == ".JPG" ||
610 filename
.right(5).upper() == ".JPEG" ||
611 filename
.right(4).upper() == ".CRW" ||
612 filename
.right(4).upper() == ".PNG" ||
613 filename
.right(4).upper() == ".BMP" ||
614 filename
.right(4).upper() == ".GIF")
616 eString tmp
= directory
+ "/" + filename
;
617 piclist
.push_back(tmp
);
621 if ((includesubdirs
== 1) && (S_ISDIR(s
.st_mode
) || S_ISLNK(s
.st_mode
)))
623 eString tmp
= directory
+ "/" + filename
;
624 dirlist
.push_back(tmp
);
630 if (!piclist
.empty())
633 for (picIt
= piclist
.begin(); picIt
!= piclist
.end(); picIt
++)
635 eString tmp
= *picIt
;
636 slideshowList
.push_back(tmp
);
639 if (!dirlist
.empty())
642 for (dirIt
= dirlist
.begin(); dirIt
!= dirlist
.end(); dirIt
++)
644 eString tmp
= *dirIt
;
645 listDirectory(tmp
, includesubdirs
);
650 bool ePictureViewer::DisplayNextImage()
652 // eDebug("DisplayNextImage {");
653 if (m_NextPic_Buffer
!= NULL
)
654 fb_display(m_NextPic_Buffer
, m_NextPic_X
, m_NextPic_Y
, m_NextPic_XPan
, m_NextPic_YPan
, m_NextPic_XPos
, m_NextPic_YPos
);
655 // eDebug("DisplayNextImage }");
659 void ePictureViewer::Zoom(float factor
)
661 // eDebug("Zoom %f {",factor);
662 showBusy(m_startx
+ 3, m_starty
+ 3, 10, 0xff, 0xff, 0);
664 int oldx
= m_NextPic_X
;
665 int oldy
= m_NextPic_Y
;
666 unsigned char *oldBuf
= m_NextPic_Buffer
;
667 m_NextPic_X
= (int)(factor
* m_NextPic_X
);
668 m_NextPic_Y
= (int)(factor
* m_NextPic_Y
);
670 if (m_scaling
== COLOR
)
671 m_NextPic_Buffer
= color_average_resize(m_NextPic_Buffer
, oldx
, oldy
, m_NextPic_X
, m_NextPic_Y
);
673 m_NextPic_Buffer
= simple_resize(m_NextPic_Buffer
, oldx
, oldy
, m_NextPic_X
, m_NextPic_Y
);
675 if (m_NextPic_Buffer
== oldBuf
)
682 if (m_NextPic_X
< (m_endx
- m_startx
))
683 m_NextPic_XPos
= (m_endx
- m_startx
- m_NextPic_X
) / 2 + m_startx
;
685 m_NextPic_XPos
= m_startx
;
686 if (m_NextPic_Y
< (m_endy
- m_starty
))
687 m_NextPic_YPos
= (m_endy
- m_starty
- m_NextPic_Y
) / 2 + m_starty
;
689 m_NextPic_YPos
= m_starty
;
690 if (m_NextPic_X
> (m_endx
- m_startx
))
691 m_NextPic_XPan
= (m_NextPic_X
- (m_endx
- m_startx
)) / 2;
694 if (m_NextPic_Y
> (m_endy
- m_starty
))
695 m_NextPic_YPan
= (m_NextPic_Y
- (m_endy
- m_starty
)) / 2;
698 fb_display(m_NextPic_Buffer
, m_NextPic_X
, m_NextPic_Y
, m_NextPic_XPan
, m_NextPic_YPan
, m_NextPic_XPos
, m_NextPic_YPos
);
701 void ePictureViewer::Move(int dx
, int dy
)
703 // eDebug("Move %d %d {", dx, dy);
704 showBusy(m_startx
+ 3, m_starty
+ 3, 10, 0, 0xff, 0);
707 getCurrentRes(&xs
, &ys
);
708 m_NextPic_XPan
+= dx
;
709 if (m_NextPic_XPan
+ xs
>= m_NextPic_X
)
710 m_NextPic_XPan
= m_NextPic_X
- xs
- 1;
711 if (m_NextPic_XPan
< 0)
714 m_NextPic_YPan
+= dy
;
715 if (m_NextPic_YPan
+ ys
>= m_NextPic_Y
)
716 m_NextPic_YPan
= m_NextPic_Y
- ys
- 1;
717 if(m_NextPic_YPan
< 0)
720 if (m_NextPic_X
< (m_endx
- m_startx
))
721 m_NextPic_XPos
= (m_endx
- m_startx
- m_NextPic_X
) / 2 + m_startx
;
723 m_NextPic_XPos
= m_startx
;
724 if (m_NextPic_Y
< (m_endy
- m_starty
))
725 m_NextPic_YPos
= (m_endy
- m_starty
- m_NextPic_Y
) / 2 + m_starty
;
727 m_NextPic_YPos
= m_starty
;
728 // dbout("Display x(%d) y(%d) xpan(%d) ypan(%d) xpos(%d) ypos(%d)\n",m_NextPic_X, m_NextPic_Y,
729 // m_NextPic_XPan, m_NextPic_YPan, m_NextPic_XPos, m_NextPic_YPos);
731 fb_display(m_NextPic_Buffer
, m_NextPic_X
, m_NextPic_Y
, m_NextPic_XPan
, m_NextPic_YPan
, m_NextPic_XPos
, m_NextPic_YPos
);
736 void ePictureViewer::showBusy(int sx
, int sy
, int width
, char r
, char g
, char b
)
738 // eDebug("Show Busy{");
740 unsigned char rgb_buffer
[3];
741 unsigned char *fb_buffer
=0;
742 unsigned char *busy_buffer_wrk
;
744 struct fb_var_screeninfo
*var
= fbClass::getInstance()->getScreenInfo();
746 bool yuv_fb
= eSystemInfo::getInstance()->getHwType() == eSystemInfo::DM600PVR
&& var
->bits_per_pixel
== 16;
754 fb_buffer
= (unsigned char *) convertRGB2FB(rgb_buffer
, 1, var
->bits_per_pixel
, &cpp
);
755 if (fb_buffer
== NULL
)
757 eDebug("Error: malloc");
764 if (m_busy_buffer
!= NULL
)
766 delete [] m_busy_buffer
;
767 m_busy_buffer
= NULL
;
769 m_busy_buffer
= new unsigned char[width
* width
* cpp
];
770 if (m_busy_buffer
== NULL
)
772 eDebug("Error: malloc");
776 busy_buffer_wrk
= m_busy_buffer
;
777 unsigned char *fb
= fbClass::getInstance()->lfb
;
778 unsigned int stride
= fbClass::getInstance()->Stride();
780 for (int y
= sy
; y
< sy
+ width
; y
++)
782 for(int x
= sx
; x
< sx
+ width
; x
++)
786 int offs
= y
* stride
+ x
;
787 busy_buffer_wrk
[0]=fb
[offs
]; // save old Y
788 busy_buffer_wrk
[1]=fb
[offs
+ 720 * 576]; // save old UV
789 fb
[offs
]=(lut_r_y
[r
] + lut_g_y
[g
] + lut_b_y
[b
]) >> 8;
791 fb
[offs
+ 720 * 576]=((lut_r_v
[r
] + lut_g_v
[g
] + lut_b_v
[b
]) >> 8) + 128;
793 fb
[offs
+ 720 * 576]=((lut_r_u
[r
] + lut_g_u
[g
] + lut_b_u
[b
]) >> 8) + 128;
797 memcpy(busy_buffer_wrk
, fb
+ y
* stride
+ x
, cpp
);
798 memcpy(fb
+ y
* stride
+ x
* cpp
, fb_buffer
, cpp
);
800 busy_buffer_wrk
+= cpp
;
806 m_busy_width
= width
;
809 // eDebug("Show Busy}");
812 void ePictureViewer::hideBusy()
814 //eDebug("Hide Busy {");
816 if (m_busy_buffer
!= NULL
)
818 unsigned char *fb
= fbClass::getInstance()->lfb
;
819 unsigned int stride
= fbClass::getInstance()->Stride();
820 unsigned char *busy_buffer_wrk
= m_busy_buffer
;
821 struct fb_var_screeninfo
*var
= fbClass::getInstance()->getScreenInfo();
822 bool yuv_fb
= eSystemInfo::getInstance()->getHwType() == eSystemInfo::DM600PVR
&& var
->bits_per_pixel
== 16;
824 for (int y
= m_busy_y
; y
< m_busy_y
+ m_busy_width
; y
++)
826 for (int x
= m_busy_x
; x
< m_busy_x
+ m_busy_width
; x
++)
830 int offs
= y
* stride
+ x
;
831 fb
[offs
]=*(busy_buffer_wrk
++);
832 fb
[offs
+ 720 * 576]=*(busy_buffer_wrk
++);
836 memcpy(fb
+ y
* stride
+ x
, busy_buffer_wrk
, m_busy_cpp
);
837 busy_buffer_wrk
+= m_busy_cpp
;
841 delete [] m_busy_buffer
;
842 m_busy_buffer
= NULL
;
844 // eDebug("Hide Busy}");