mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 00:11:14 +02:00
Correct calculation of the size of logo in list header.
- Function for calculating from infoviewer.cpp to pictureviewer.cpp moved - Correct calculation in channellist.cpp, epgview.cpp and moviebrowser.cpp git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-beta@1869 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
@@ -510,6 +510,23 @@ bool CPictureViewer::DisplayLogo (uint64_t channel_id, int posx, int posy, int w
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CPictureViewer::rescaleImageDimensions(int *width, int *height, const int max_width, const int max_height, bool upscale)
|
||||||
|
{
|
||||||
|
float aspect;
|
||||||
|
|
||||||
|
if ((!upscale) && (*width <= max_width) && (*height <= max_height))
|
||||||
|
return;
|
||||||
|
|
||||||
|
aspect = (float)(*width) / (float)(*height);
|
||||||
|
if (((float)(*width) / (float)max_width) > ((float)(*height) / (float)max_height)) {
|
||||||
|
*width = max_width;
|
||||||
|
*height = (int)(max_width / aspect);
|
||||||
|
}else{
|
||||||
|
*height = max_height;
|
||||||
|
*width = (int)(max_height * aspect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool CPictureViewer::DisplayImage (const std::string & name, int posx, int posy, int width, int height)
|
bool CPictureViewer::DisplayImage (const std::string & name, int posx, int posy, int width, int height)
|
||||||
{
|
{
|
||||||
/* TODO: cache or check for same */
|
/* TODO: cache or check for same */
|
||||||
|
@@ -70,6 +70,7 @@ class CPictureViewer
|
|||||||
void getSize(const char *name, int* width, int *height);
|
void getSize(const char *name, int* width, int *height);
|
||||||
unsigned char * Resize(unsigned char *orgin, int ox, int oy, int dx, int dy, ScalingMode type, unsigned char * dst = NULL);
|
unsigned char * Resize(unsigned char *orgin, int ox, int oy, int dx, int dy, ScalingMode type, unsigned char * dst = NULL);
|
||||||
unsigned char * ResizeA(unsigned char *orgin, int ox, int oy, int dx, int dy);
|
unsigned char * ResizeA(unsigned char *orgin, int ox, int oy, int dx, int dy);
|
||||||
|
void rescaleImageDimensions(int *width, int *height, const int max_width, const int max_height, bool upscale=false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CFormathandler *fh_root;
|
CFormathandler *fh_root;
|
||||||
|
@@ -1771,16 +1771,13 @@ void CChannelList::showChannelLogo()
|
|||||||
if(g_settings.infobar_show_channellogo){
|
if(g_settings.infobar_show_channellogo){
|
||||||
static int logo_w = 0;
|
static int logo_w = 0;
|
||||||
static int logo_h = 0;
|
static int logo_h = 0;
|
||||||
|
int logo_w_max = width / 4;
|
||||||
frameBuffer->paintBoxRel(x + width - logo_off - logo_w, y+(theight-logo_h)/2, logo_w, logo_h, COL_MENUHEAD_PLUS_0);
|
frameBuffer->paintBoxRel(x + width - logo_off - logo_w, y+(theight-logo_h)/2, logo_w, logo_h, COL_MENUHEAD_PLUS_0);
|
||||||
|
|
||||||
std::string lname;
|
std::string lname;
|
||||||
if(g_PicViewer->GetLogoName(chanlist[selected]->channel_id, chanlist[selected]->name, lname, &logo_w, &logo_h)) {
|
if(g_PicViewer->GetLogoName(chanlist[selected]->channel_id, chanlist[selected]->name, lname, &logo_w, &logo_h)) {
|
||||||
if(logo_h > theight) {
|
if((logo_h > theight) || (logo_w > logo_w_max))
|
||||||
if((theight/(logo_h-theight))>1) {
|
g_PicViewer->rescaleImageDimensions(&logo_w, &logo_h, logo_w_max, theight);
|
||||||
logo_w -= (logo_w/(theight/(logo_h-theight)));
|
|
||||||
}
|
|
||||||
logo_h = theight;
|
|
||||||
}
|
|
||||||
g_PicViewer->DisplayImage(lname, x + width - logo_off - logo_w, y+(theight-logo_h)/2, logo_w, logo_h);
|
g_PicViewer->DisplayImage(lname, x + width - logo_off - logo_w, y+(theight-logo_h)/2, logo_w, logo_h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -489,15 +489,12 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start
|
|||||||
std::string lname;
|
std::string lname;
|
||||||
int logo_w = 0;
|
int logo_w = 0;
|
||||||
int logo_h = 0;
|
int logo_h = 0;
|
||||||
|
int logo_w_max = ox / 4;
|
||||||
CZapitChannel * channel = CServiceManager::getInstance()->FindChannel(channel_id);
|
CZapitChannel * channel = CServiceManager::getInstance()->FindChannel(channel_id);
|
||||||
if(channel) {
|
if(channel) {
|
||||||
if(g_settings.infobar_show_channellogo && g_PicViewer->GetLogoName(channel_id, channel->getName(), lname, &logo_w, &logo_h)) {
|
if(g_settings.infobar_show_channellogo && g_PicViewer->GetLogoName(channel_id, channel->getName(), lname, &logo_w, &logo_h)) {
|
||||||
if(logo_h > toph){
|
if((logo_h > toph) || (logo_w > logo_w_max))
|
||||||
if((toph/(logo_h-toph))>1){
|
g_PicViewer->rescaleImageDimensions(&logo_w, &logo_h, logo_w_max, toph);
|
||||||
logo_w -= (logo_w/(toph/(logo_h-toph)));
|
|
||||||
}
|
|
||||||
logo_h = toph;
|
|
||||||
}
|
|
||||||
pic_offx = logo_w + 10;
|
pic_offx = logo_w + 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2050,31 +2050,6 @@ void CInfoViewer::Set_CA_Status (int /*Status*/)
|
|||||||
showIcon_CA_Status (1);
|
showIcon_CA_Status (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* resize the logo, preserving the aspect ratio */
|
|
||||||
static void resize_logo(int *w, int *h, const int width, const int height)
|
|
||||||
{
|
|
||||||
//fprintf(stderr, "resize_logo(%d, %d, %d, %d)\n", *w, *h, width, height);
|
|
||||||
float aspect;
|
|
||||||
|
|
||||||
if (*w <= width && *h <= height) // should we also increase the size? Not yet.
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* i hate floats ... :) */
|
|
||||||
aspect = (float)(*w) / (float)(*h);
|
|
||||||
|
|
||||||
if (((float)(*w) / (float)width) > ((float)(*h) / (float)height))
|
|
||||||
{
|
|
||||||
*w = width;
|
|
||||||
*h = (int)(width / aspect);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*h = height;
|
|
||||||
*w = (int)(height * aspect);
|
|
||||||
}
|
|
||||||
//fprintf(stderr, "resize_logo(%d, %d, %d, %d) aspect: %f\n", *w, *h, width, height, aspect);
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
returns mode of painted channel logo,
|
returns mode of painted channel logo,
|
||||||
0 = no logo painted
|
0 = no logo painted
|
||||||
@@ -2118,7 +2093,7 @@ int CInfoViewer::showChannelLogo(const t_channel_id logo_channel_id, const int c
|
|||||||
int x_mid = BoxStartX + ChanWidth / 2;
|
int x_mid = BoxStartX + ChanWidth / 2;
|
||||||
y_mid = BoxStartY + (satNameHeight + ChanHeight) / 2;
|
y_mid = BoxStartY + (satNameHeight + ChanHeight) / 2;
|
||||||
|
|
||||||
resize_logo(&logo_w, &logo_h, ChanWidth, ChanHeight - satNameHeight);
|
g_PicViewer->rescaleImageDimensions(&logo_w, &logo_h, ChanWidth, ChanHeight - satNameHeight);
|
||||||
// channel name with number
|
// channel name with number
|
||||||
// this is too ugly... ChannelName = (std::string)strChanNum + ". " + ChannelName;
|
// this is too ugly... ChannelName = (std::string)strChanNum + ". " + ChannelName;
|
||||||
// get position of channel logo, must be centered in number box
|
// get position of channel logo, must be centered in number box
|
||||||
@@ -2129,7 +2104,7 @@ int CInfoViewer::showChannelLogo(const t_channel_id logo_channel_id, const int c
|
|||||||
else if (g_settings.infobar_show_channellogo == 2 || g_settings.infobar_show_channellogo == 5 || g_settings.infobar_show_channellogo == 6) // paint logo in place of channel name
|
else if (g_settings.infobar_show_channellogo == 2 || g_settings.infobar_show_channellogo == 5 || g_settings.infobar_show_channellogo == 6) // paint logo in place of channel name
|
||||||
{
|
{
|
||||||
// check logo dimensions
|
// check logo dimensions
|
||||||
resize_logo(&logo_w, &logo_h, chan_w, time_height);
|
g_PicViewer->rescaleImageDimensions(&logo_w, &logo_h, chan_w, time_height);
|
||||||
// hide channel name
|
// hide channel name
|
||||||
// this is too ugly... ChannelName = "";
|
// this is too ugly... ChannelName = "";
|
||||||
// calculate logo position
|
// calculate logo position
|
||||||
@@ -2145,7 +2120,7 @@ int CInfoViewer::showChannelLogo(const t_channel_id logo_channel_id, const int c
|
|||||||
{
|
{
|
||||||
// check logo dimensions
|
// check logo dimensions
|
||||||
int Logo_max_width = chan_w - logo_w - 10;
|
int Logo_max_width = chan_w - logo_w - 10;
|
||||||
resize_logo(&logo_w, &logo_h, Logo_max_width, time_height);
|
g_PicViewer->rescaleImageDimensions(&logo_w, &logo_h, Logo_max_width, time_height);
|
||||||
// calculate logo position
|
// calculate logo position
|
||||||
y_mid = ChanNameY + time_height / 2;
|
y_mid = ChanNameY + time_height / 2;
|
||||||
logo_x = start_x + 10;
|
logo_x = start_x + 10;
|
||||||
|
@@ -1204,24 +1204,20 @@ void CMovieBrowser::refreshMovieInfo(void)
|
|||||||
m_pcInfo->setText(&m_movieSelectionHandler->epgInfo2, logo_ok ? m_cBoxFrameInfo.iWidth-picw-20: 0);
|
m_pcInfo->setText(&m_movieSelectionHandler->epgInfo2, logo_ok ? m_cBoxFrameInfo.iWidth-picw-20: 0);
|
||||||
static int logo_w = 0;
|
static int logo_w = 0;
|
||||||
static int logo_h = 0;
|
static int logo_h = 0;
|
||||||
|
int logo_w_max = m_cBoxFrameTitleRel.iWidth / 4;
|
||||||
|
|
||||||
//printf("refreshMovieInfo: EpgId %llx id %llx y %d\n", m_movieSelectionHandler->epgEpgId, m_movieSelectionHandler->epgId, m_cBoxFrameTitleRel.iY);
|
//printf("refreshMovieInfo: EpgId %llx id %llx y %d\n", m_movieSelectionHandler->epgEpgId, m_movieSelectionHandler->epgId, m_cBoxFrameTitleRel.iY);
|
||||||
int lx = m_cBoxFrame.iX+m_cBoxFrameTitleRel.iX+m_cBoxFrameTitleRel.iWidth-logo_w-10;
|
int lx = m_cBoxFrame.iX+m_cBoxFrameTitleRel.iX+m_cBoxFrameTitleRel.iWidth-logo_w-10;
|
||||||
int ly = m_cBoxFrameTitleRel.iY+m_cBoxFrame.iY+ (m_cBoxFrameTitleRel.iHeight-logo_h)/2;
|
int ly = m_cBoxFrameTitleRel.iY+m_cBoxFrame.iY+ (m_cBoxFrameTitleRel.iHeight-logo_h)/2;
|
||||||
const short pb_hdd_offset = 104;
|
const short pb_hdd_offset = 104;
|
||||||
m_pcWindow->paintBoxRel(lx - pb_hdd_offset , ly, logo_w, logo_h, TITLE_BACKGROUND_COLOR);
|
m_pcWindow->paintBoxRel(lx - pb_hdd_offset , ly, logo_w, logo_h, TITLE_BACKGROUND_COLOR);
|
||||||
//g_PicViewer->DisplayLogo(m_movieSelectionHandler->epgEpgId >>16, lx, ly, PIC_W, PIC_H);
|
|
||||||
std::string lname;
|
std::string lname;
|
||||||
if(g_PicViewer->GetLogoName(m_movieSelectionHandler->epgEpgId >>16, m_movieSelectionHandler->epgChannel, lname, &logo_w, &logo_h)){
|
if(g_PicViewer->GetLogoName(m_movieSelectionHandler->epgEpgId >>16, m_movieSelectionHandler->epgChannel, lname, &logo_w, &logo_h)){
|
||||||
if(logo_h > m_cBoxFrameTitleRel.iHeight){
|
if((logo_h > m_cBoxFrameTitleRel.iHeight) || (logo_w > logo_w_max))
|
||||||
if((m_cBoxFrameTitleRel.iHeight/(logo_h-m_cBoxFrameTitleRel.iHeight))>1){
|
g_PicViewer->rescaleImageDimensions(&logo_w, &logo_h, logo_w_max, m_cBoxFrameTitleRel.iHeight);
|
||||||
logo_w -= (logo_w/(m_cBoxFrameTitleRel.iHeight/(logo_h-m_cBoxFrameTitleRel.iHeight)));
|
lx = m_cBoxFrame.iX+m_cBoxFrameTitleRel.iX+m_cBoxFrameTitleRel.iWidth-logo_w-10;
|
||||||
}
|
ly = m_cBoxFrameTitleRel.iY+m_cBoxFrame.iY+ (m_cBoxFrameTitleRel.iHeight-logo_h)/2;
|
||||||
logo_h = m_cBoxFrameTitleRel.iHeight;
|
g_PicViewer->DisplayImage(lname, lx - pb_hdd_offset, ly, logo_w, logo_h);
|
||||||
}
|
|
||||||
lx = m_cBoxFrame.iX+m_cBoxFrameTitleRel.iX+m_cBoxFrameTitleRel.iWidth-logo_w-10;
|
|
||||||
ly = m_cBoxFrameTitleRel.iY+m_cBoxFrame.iY+ (m_cBoxFrameTitleRel.iHeight-logo_h)/2;
|
|
||||||
g_PicViewer->DisplayImage(lname, lx - pb_hdd_offset, ly, logo_w, logo_h);
|
|
||||||
}
|
}
|
||||||
if(logo_ok) {
|
if(logo_ok) {
|
||||||
#if 0
|
#if 0
|
||||||
@@ -1229,13 +1225,17 @@ void CMovieBrowser::refreshMovieInfo(void)
|
|||||||
ly = m_cBoxFrameInfo.iY + (m_cBoxFrameInfo.iHeight-pich)/2;
|
ly = m_cBoxFrameInfo.iY + (m_cBoxFrameInfo.iHeight-pich)/2;
|
||||||
g_PicViewer->DisplayImage(fname, lx, ly, picw, pich);
|
g_PicViewer->DisplayImage(fname, lx, ly, picw, pich);
|
||||||
#endif
|
#endif
|
||||||
lx = m_cBoxFrameInfo.iX+m_cBoxFrameInfo.iWidth - picw -10;
|
|
||||||
ly = m_cBoxFrameInfo.iY + (m_cBoxFrameInfo.iHeight-pich)/2;
|
int flogo_w = 0, flogo_h = 0;
|
||||||
m_pcWindow->paintVLineRel(lx, ly, pich, COL_WHITE);
|
g_PicViewer->getSize(fname.c_str(), &flogo_w, &flogo_h);
|
||||||
m_pcWindow->paintVLineRel(lx+picw, ly, pich, COL_WHITE);
|
g_PicViewer->rescaleImageDimensions(&flogo_w, &flogo_h, picw, pich);
|
||||||
m_pcWindow->paintHLineRel(lx, picw, ly, COL_WHITE);
|
lx = m_cBoxFrameInfo.iX+m_cBoxFrameInfo.iWidth - flogo_w -10;
|
||||||
m_pcWindow->paintHLineRel(lx, picw, ly+pich, COL_WHITE);
|
ly = m_cBoxFrameInfo.iY + (m_cBoxFrameInfo.iHeight-flogo_h)/2;
|
||||||
g_PicViewer->DisplayImage(fname, lx+3, ly+3, picw-3, pich-3);
|
m_pcWindow->paintVLineRel(lx, ly, flogo_h, COL_WHITE);
|
||||||
|
m_pcWindow->paintVLineRel(lx+flogo_w, ly, flogo_h, COL_WHITE);
|
||||||
|
m_pcWindow->paintHLineRel(lx, flogo_w, ly, COL_WHITE);
|
||||||
|
m_pcWindow->paintHLineRel(lx, flogo_w, ly+flogo_h, COL_WHITE);
|
||||||
|
g_PicViewer->DisplayImage(fname, lx+3, ly+3, flogo_w-3, flogo_h-3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user