mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-18 02:43:42 +02:00
Merge remote-tracking branch 'uncool/cst-next'
This need buildfixes and some functional updates...
This commit is contained in:
@@ -3,14 +3,14 @@
|
||||
#include <neutrino.h>
|
||||
#include "pictureviewer.h"
|
||||
#include "pv_config.h"
|
||||
|
||||
#include <system/debug.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <cs_api.h>
|
||||
|
||||
#ifdef FBV_SUPPORT_GIF
|
||||
@@ -166,10 +166,11 @@ bool CPictureViewer::DecodeImage (const std::string & _name, bool showBusySign,
|
||||
if (fh) {
|
||||
if (m_NextPic_Buffer != NULL) {
|
||||
free (m_NextPic_Buffer);
|
||||
m_NextPic_Buffer = NULL;
|
||||
}
|
||||
m_NextPic_Buffer = (unsigned char *) malloc (x * y * 3);
|
||||
if (m_NextPic_Buffer == NULL) {
|
||||
printf ("DecodeImage: Error: malloc\n");
|
||||
dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: malloc, %s\n", __func__, __LINE__, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
// dbout("---Decoding Start(%d/%d)\n",x,y);
|
||||
@@ -206,11 +207,11 @@ bool CPictureViewer::DecodeImage (const std::string & _name, bool showBusySign,
|
||||
else
|
||||
m_NextPic_YPan = 0;
|
||||
} else {
|
||||
printf ("Unable to read file !\n");
|
||||
dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: Unable to read file !, %s\n", __func__, __LINE__, strerror(errno));
|
||||
free (m_NextPic_Buffer);
|
||||
m_NextPic_Buffer = (unsigned char *) malloc (3);
|
||||
if (m_NextPic_Buffer == NULL) {
|
||||
printf ("DecodeImage: Error: malloc\n");
|
||||
dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: malloc, %s\n", __func__, __LINE__, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
memset (m_NextPic_Buffer, 0, 3);
|
||||
@@ -222,13 +223,14 @@ bool CPictureViewer::DecodeImage (const std::string & _name, bool showBusySign,
|
||||
m_NextPic_YPan = 0;
|
||||
}
|
||||
} else {
|
||||
printf ("Unable to read file or format not recognized!\n");
|
||||
dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Unable to read file or format not recognized!\n", __func__, __LINE__);
|
||||
if (m_NextPic_Buffer != NULL) {
|
||||
free (m_NextPic_Buffer);
|
||||
m_NextPic_Buffer = NULL;
|
||||
}
|
||||
m_NextPic_Buffer = (unsigned char *) malloc (3);
|
||||
if (m_NextPic_Buffer == NULL) {
|
||||
printf ("DecodeImage: Error: malloc\n");
|
||||
dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: malloc, %s\n", __func__, __LINE__, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
memset (m_NextPic_Buffer, 0, 3);
|
||||
@@ -264,8 +266,8 @@ bool CPictureViewer::ShowImage (const std::string & filename, bool unscaled)
|
||||
free (m_CurrentPic_Buffer);
|
||||
m_CurrentPic_Buffer = NULL;
|
||||
}
|
||||
DecodeImage (filename, true, unscaled);
|
||||
DisplayNextImage ();
|
||||
if (DecodeImage (filename, true, unscaled))
|
||||
DisplayNextImage ();
|
||||
// dbout("Show Image }\n");
|
||||
return true;
|
||||
}
|
||||
@@ -302,8 +304,8 @@ void CPictureViewer::Zoom (float factor)
|
||||
int oldx = m_CurrentPic_X;
|
||||
int oldy = m_CurrentPic_Y;
|
||||
unsigned char *oldBuf = m_CurrentPic_Buffer;
|
||||
m_CurrentPic_X = (int) (factor * m_CurrentPic_X);
|
||||
m_CurrentPic_Y = (int) (factor * m_CurrentPic_Y);
|
||||
m_CurrentPic_X = int(factor * (float)m_CurrentPic_X);
|
||||
m_CurrentPic_Y = int(factor * (float)m_CurrentPic_Y);
|
||||
|
||||
m_CurrentPic_Buffer = Resize(m_CurrentPic_Buffer, oldx, oldy, m_CurrentPic_X, m_CurrentPic_Y, m_scaling);
|
||||
|
||||
@@ -377,7 +379,7 @@ CPictureViewer::CPictureViewer ()
|
||||
fh_root = NULL;
|
||||
m_scaling = COLOR;
|
||||
//m_aspect = 4.0 / 3;
|
||||
m_aspect = 16.0 / 9;
|
||||
m_aspect = float(16.0 / 9.0);
|
||||
m_CurrentPic_Name = "";
|
||||
m_CurrentPic_Buffer = NULL;
|
||||
m_CurrentPic_X = 0;
|
||||
@@ -434,7 +436,7 @@ void CPictureViewer::showBusy (int sx, int sy, int width, char r, char g, char b
|
||||
|
||||
fb_buffer = (unsigned char *) CFrameBuffer::getInstance()->convertRGB2FB (rgb_buffer, 1, 1);
|
||||
if (fb_buffer == NULL) {
|
||||
printf ("showBusy: Error: malloc 1\n");
|
||||
dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: malloc\n", __func__, __LINE__);
|
||||
return;
|
||||
}
|
||||
if (m_busy_buffer != NULL) {
|
||||
@@ -443,7 +445,7 @@ void CPictureViewer::showBusy (int sx, int sy, int width, char r, char g, char b
|
||||
}
|
||||
m_busy_buffer = (unsigned char *) malloc (width * width * cpp);
|
||||
if (m_busy_buffer == NULL) {
|
||||
printf ("showBusy: Error: malloc 2: \n");
|
||||
dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Error: malloc\n", __func__, __LINE__);
|
||||
return;
|
||||
}
|
||||
busy_buffer_wrk = m_busy_buffer;
|
||||
@@ -511,9 +513,6 @@ void CPictureViewer::getSize(const char* name, int* width, int *height)
|
||||
}
|
||||
}
|
||||
|
||||
#define LOGO_FLASH_DIR DATADIR "/neutrino/icons/logo"
|
||||
#define LOGO_FLASH_DIR_VAR "/var/tuxbox/icons/logo"
|
||||
|
||||
bool CPictureViewer::GetLogoName(const uint64_t& channel_id, const std::string& ChannelName, std::string & name, int *width, int *height)
|
||||
{
|
||||
std::string fileType[] = { ".png", ".jpg" , ".gif" };
|
||||
@@ -537,25 +536,25 @@ bool CPictureViewer::GetLogoName(const uint64_t& channel_id, const std::string&
|
||||
id_tmp_path += strChnId + fileType[i];
|
||||
v_path.push_back(id_tmp_path);
|
||||
|
||||
if(g_settings.logo_hdd_dir != LOGO_FLASH_DIR_VAR){
|
||||
//create filename with channel name (LOGO_FLASH_DIR_VAR)
|
||||
id_tmp_path = LOGO_FLASH_DIR_VAR "/";
|
||||
if(g_settings.logo_hdd_dir != LOGODIR_VAR){
|
||||
//create filename with channel name (LOGODIR_VAR)
|
||||
id_tmp_path = LOGODIR_VAR "/";
|
||||
id_tmp_path += ChannelName + fileType[i];
|
||||
v_path.push_back(id_tmp_path);
|
||||
|
||||
//create filename with id (LOGO_FLASH_DIR_VAR)
|
||||
id_tmp_path = LOGO_FLASH_DIR_VAR "/";
|
||||
//create filename with id (LOGODIR_VAR)
|
||||
id_tmp_path = LOGODIR_VAR "/";
|
||||
id_tmp_path += strChnId + fileType[i];
|
||||
v_path.push_back(id_tmp_path);
|
||||
}
|
||||
if(g_settings.logo_hdd_dir != LOGO_FLASH_DIR){
|
||||
//create filename with channel name (LOGO_FLASH_DIR)
|
||||
id_tmp_path = LOGO_FLASH_DIR "/";
|
||||
if(g_settings.logo_hdd_dir != LOGODIR){
|
||||
//create filename with channel name (LOGODIR)
|
||||
id_tmp_path = LOGODIR "/";
|
||||
id_tmp_path += ChannelName + fileType[i];
|
||||
v_path.push_back(id_tmp_path);
|
||||
|
||||
//create filename with id (LOGO_FLASH_DIR)
|
||||
id_tmp_path = LOGO_FLASH_DIR "/";
|
||||
//create filename with id (LOGODIR)
|
||||
id_tmp_path = LOGODIR "/";
|
||||
id_tmp_path += strChnId + fileType[i];
|
||||
v_path.push_back(id_tmp_path);
|
||||
}
|
||||
@@ -607,10 +606,10 @@ void CPictureViewer::rescaleImageDimensions(int *width, int *height, const int m
|
||||
aspect = (float)(*width) / (float)(*height);
|
||||
if (((float)(*width) / (float)max_width) > ((float)(*height) / (float)max_height)) {
|
||||
*width = max_width;
|
||||
*height = (int)(max_width / aspect);
|
||||
*height = int((float)max_width / aspect);
|
||||
}else{
|
||||
*height = max_height;
|
||||
*width = (int)(max_height * aspect);
|
||||
*width = int((float)max_height * aspect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -623,22 +622,27 @@ bool CPictureViewer::DisplayImage(const std::string & name, int posx, int posy,
|
||||
/* TODO: cache or check for same */
|
||||
fb_pixel_t * data = getImage(name, width, height);
|
||||
|
||||
if (transp > CFrameBuffer::TM_EMPTY)
|
||||
frameBuffer->SetTransparentDefault();
|
||||
if (data){
|
||||
if (transp > CFrameBuffer::TM_EMPTY)
|
||||
frameBuffer->SetTransparentDefault();
|
||||
|
||||
if(data) {
|
||||
frameBuffer->blit2FB(data, width, height, posx, posy);
|
||||
cs_free_uncached(data);
|
||||
return true;
|
||||
if(data) {
|
||||
frameBuffer->blit2FB(data, width, height, posx, posy);
|
||||
cs_free_uncached(data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
fb_pixel_t * CPictureViewer::int_getImage(const std::string & name, int *width, int *height, bool GetImage)
|
||||
{
|
||||
if (access(name.c_str(), R_OK) == -1)
|
||||
return NULL;
|
||||
|
||||
int x, y, load_ret, bpp = 0;
|
||||
CFormathandler *fh;
|
||||
unsigned char * buffer;
|
||||
CFormathandler *fh = NULL;
|
||||
unsigned char * buffer = NULL;
|
||||
fb_pixel_t * ret = NULL;
|
||||
std::string mode_str;
|
||||
|
||||
@@ -653,8 +657,8 @@ fb_pixel_t * CPictureViewer::int_getImage(const std::string & name, int *width,
|
||||
buffer = (unsigned char *) malloc(x * y * 4);
|
||||
if (buffer == NULL)
|
||||
{
|
||||
printf("%s: Error: malloc\n", mode_str.c_str());
|
||||
return 0;
|
||||
dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] mode %s: Error: malloc\n", __func__, __LINE__, mode_str.c_str());
|
||||
return NULL;
|
||||
}
|
||||
#ifdef FBV_SUPPORT_PNG
|
||||
if ((name.find(".png") == (name.length() - 4)) && (fh_png_id(name.c_str())))
|
||||
@@ -662,13 +666,15 @@ fb_pixel_t * CPictureViewer::int_getImage(const std::string & name, int *width,
|
||||
else
|
||||
#endif
|
||||
load_ret = fh->get_pic(name.c_str (), &buffer, &x, &y);
|
||||
dprintf(DEBUG_INFO, "[CPictureViewer] [%s - %d] load_result: %d \n", __func__, __LINE__, load_ret);
|
||||
|
||||
if (load_ret == FH_ERROR_OK)
|
||||
{
|
||||
// printf("%s: decoded %s, %d x %d \n", mode_str.c_str(), name.c_str(), x, y);
|
||||
dprintf(DEBUG_INFO, "[CPictureViewer] [%s - %d] mode %s, decoded %s, (Pos: %d %d) ,bpp = %d \n", __func__, __LINE__, mode_str.c_str(), name.c_str(), x, y, bpp);
|
||||
// resize only getImage
|
||||
if ((GetImage) && (x != *width || y != *height))
|
||||
{
|
||||
printf("%s: resize %s to %d x %d \n", mode_str.c_str(), name.c_str(), *width, *height);
|
||||
dprintf(DEBUG_INFO, "[CPictureViewer] [%s - %d] resize %s to %d x %d \n", __func__, __LINE__, name.c_str(), *width, *height);
|
||||
if (bpp == 4)
|
||||
buffer = ResizeA(buffer, x, y, *width, *height);
|
||||
else
|
||||
@@ -682,11 +688,13 @@ fb_pixel_t * CPictureViewer::int_getImage(const std::string & name, int *width,
|
||||
ret = (fb_pixel_t *) CFrameBuffer::getInstance()->convertRGB2FB(buffer, x, y, convertSetupAlpha2Alpha(g_settings.theme.infobar_alpha));
|
||||
*width = x;
|
||||
*height = y;
|
||||
}else
|
||||
printf("%s: Error decoding file %s\n", mode_str.c_str(), name.c_str());
|
||||
}else{
|
||||
dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] mode %s: Error decoding file %s\n", __func__, __LINE__, mode_str.c_str(), name.c_str());
|
||||
return NULL;
|
||||
}
|
||||
free(buffer);
|
||||
}else
|
||||
printf("%s: Error open file %s\n", mode_str.c_str(), name.c_str());
|
||||
dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] mode: %s, file: %s Error: %s, buffer = %p (Pos: %d %d, Dim: %d x %d)\n", __func__, __LINE__, mode_str.c_str(), name.c_str(), strerror(errno), buffer, x, y, *width, *height);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -709,7 +717,7 @@ unsigned char * CPictureViewer::int_Resize(unsigned char *orgin, int ox, int oy,
|
||||
|
||||
if(cr == NULL)
|
||||
{
|
||||
printf("Resize Error: malloc\n");
|
||||
dprintf(DEBUG_NORMAL, "[CPictureViewer] [%s - %d] Resize Error: malloc\n", __func__, __LINE__);
|
||||
return(orgin);
|
||||
}
|
||||
}else
|
||||
@@ -765,7 +773,10 @@ unsigned char * CPictureViewer::int_Resize(unsigned char *orgin, int ox, int oy,
|
||||
r+=q[0]; g+=q[1]; b+=q[2]; a+=q[3];
|
||||
}
|
||||
}
|
||||
p[0]=r/sq; p[1]=g/sq; p[2]=b/sq; p[3]=a/sq;
|
||||
p[0]= uint8_t(r/sq);
|
||||
p[1]= uint8_t(g/sq);
|
||||
p[2]= uint8_t(b/sq);
|
||||
p[3]= uint8_t(a/sq);
|
||||
}
|
||||
}
|
||||
}else
|
||||
@@ -784,7 +795,9 @@ unsigned char * CPictureViewer::int_Resize(unsigned char *orgin, int ox, int oy,
|
||||
r+=q[0]; g+=q[1]; b+=q[2];
|
||||
}
|
||||
}
|
||||
p[0]=r/sq; p[1]=g/sq; p[2]=b/sq;
|
||||
p[0]= uint8_t(r/sq);
|
||||
p[1]= uint8_t(g/sq);
|
||||
p[2]= uint8_t(b/sq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user