mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-29 16:31:11 +02:00
* CComponents::CComponentsPicture: Add the processing and scaling images
This commit is contained in:
@@ -89,6 +89,12 @@ enum
|
|||||||
CC_ALIGN_VER_CENTER = 16
|
CC_ALIGN_VER_CENTER = 16
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
CC_PIC_ICON,
|
||||||
|
CC_PIC_IMAGE
|
||||||
|
};
|
||||||
|
|
||||||
#define CC_WIDTH_MIN 16
|
#define CC_WIDTH_MIN 16
|
||||||
#define CC_HEIGHT_MIN 16
|
#define CC_HEIGHT_MIN 16
|
||||||
#define CC_SHADOW_ON true
|
#define CC_SHADOW_ON true
|
||||||
@@ -172,11 +178,18 @@ class CComponentsPicture : public CComponentsContainer
|
|||||||
unsigned char pic_offset;
|
unsigned char pic_offset;
|
||||||
bool pic_paint, pic_paintBg, pic_painted, do_paint;
|
bool pic_paint, pic_paintBg, pic_painted, do_paint;
|
||||||
int pic_align, pic_x, pic_y, pic_width, pic_height;
|
int pic_align, pic_x, pic_y, pic_width, pic_height;
|
||||||
|
int maxWidth, maxHeight, picMode;
|
||||||
|
|
||||||
void initVarPicture();
|
void initVarPicture();
|
||||||
|
void init( const int x_pos, const int y_pos, const std::string& picture_name, const int alignment, bool has_shadow,
|
||||||
|
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CComponentsPicture( const int x_pos, const int y_pos, const std::string& picture_name, const int alignment = CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, bool has_shadow = CC_SHADOW_OFF,
|
CComponentsPicture( const int x_pos, const int y_pos,
|
||||||
|
const std::string& picture_name, const int alignment = CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, bool has_shadow = CC_SHADOW_OFF,
|
||||||
|
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_background = 0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
|
||||||
|
CComponentsPicture( const int x_pos, const int y_pos, const int w_max, const int h_max,
|
||||||
|
const std::string& picture_name, const int alignment = CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER, bool has_shadow = CC_SHADOW_OFF,
|
||||||
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_background = 0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
|
fb_pixel_t color_frame = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_background = 0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0);
|
||||||
void setPictureOffset(const unsigned char offset){pic_offset = offset;};
|
void setPictureOffset(const unsigned char offset){pic_offset = offset;};
|
||||||
void setPicturePaint(bool paint_p){pic_paint = paint_p;};
|
void setPicturePaint(bool paint_p){pic_paint = paint_p;};
|
||||||
|
@@ -31,10 +31,12 @@
|
|||||||
#include <global.h>
|
#include <global.h>
|
||||||
#include <neutrino.h>
|
#include <neutrino.h>
|
||||||
#include "cc.h"
|
#include "cc.h"
|
||||||
|
#include <driver/pictureviewer/pictureviewer.h>
|
||||||
|
|
||||||
#include <video.h>
|
#include <video.h>
|
||||||
|
|
||||||
extern cVideo * videoDecoder;
|
extern cVideo * videoDecoder;
|
||||||
|
extern CPictureViewer * g_PicViewer;
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -669,8 +671,34 @@ void CComponentsPIP::hide(bool no_restore)
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------
|
||||||
//sub class CComponentsPicture from CComponentsContainer
|
//sub class CComponentsPicture from CComponentsContainer
|
||||||
CComponentsPicture::CComponentsPicture( int x_pos, int y_pos, const string& picture_name, const int alignment, bool has_shadow,
|
CComponentsPicture::CComponentsPicture( const int x_pos, const int y_pos,
|
||||||
|
const std::string& picture_name, const int alignment, bool has_shadow,
|
||||||
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow)
|
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow)
|
||||||
|
{
|
||||||
|
init(x_pos, y_pos, picture_name, alignment, has_shadow, color_frame, color_background, color_shadow);
|
||||||
|
|
||||||
|
maxWidth = 0;
|
||||||
|
maxHeight = 0;
|
||||||
|
picMode = CC_PIC_ICON;
|
||||||
|
|
||||||
|
initVarPicture();
|
||||||
|
}
|
||||||
|
|
||||||
|
CComponentsPicture::CComponentsPicture( const int x_pos, const int y_pos, const int w_max, const int h_max,
|
||||||
|
const std::string& picture_name, const int alignment, bool has_shadow,
|
||||||
|
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow)
|
||||||
|
{
|
||||||
|
init(x_pos, y_pos, picture_name, alignment, has_shadow, color_frame, color_background, color_shadow);
|
||||||
|
|
||||||
|
maxWidth = w_max;
|
||||||
|
maxHeight = h_max;
|
||||||
|
picMode = CC_PIC_IMAGE;
|
||||||
|
|
||||||
|
initVarPicture();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CComponentsPicture::init( int x_pos, int y_pos, const string& picture_name, const int alignment, bool has_shadow,
|
||||||
|
fb_pixel_t color_frame, fb_pixel_t color_background, fb_pixel_t color_shadow)
|
||||||
{
|
{
|
||||||
//CComponents, CComponentsContainer
|
//CComponents, CComponentsContainer
|
||||||
initVarContainer();
|
initVarContainer();
|
||||||
@@ -699,11 +727,8 @@ CComponentsPicture::CComponentsPicture( int x_pos, int y_pos, const string& pict
|
|||||||
firstPaint = true;
|
firstPaint = true;
|
||||||
v_fbdata.clear();
|
v_fbdata.clear();
|
||||||
bgMode = CC_BGMODE_PERMANENT;
|
bgMode = CC_BGMODE_PERMANENT;
|
||||||
|
|
||||||
initVarPicture();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CComponentsPicture::setPicture(const std::string& picture_name)
|
void CComponentsPicture::setPicture(const std::string& picture_name)
|
||||||
{
|
{
|
||||||
pic_name = picture_name;
|
pic_name = picture_name;
|
||||||
@@ -723,15 +748,21 @@ void CComponentsPicture::initVarPicture()
|
|||||||
pic_width = pic_height = 0;
|
pic_width = pic_height = 0;
|
||||||
pic_painted = false;
|
pic_painted = false;
|
||||||
do_paint = false;
|
do_paint = false;
|
||||||
|
|
||||||
frameBuffer->getIconSize(pic_name.c_str(), &pic_width, &pic_height);
|
if (picMode == CC_PIC_ICON)
|
||||||
|
frameBuffer->getIconSize(pic_name.c_str(), &pic_width, &pic_height);
|
||||||
|
else {
|
||||||
|
g_PicViewer->getSize(pic_name.c_str(), &pic_width, &pic_height);
|
||||||
|
if((pic_width > maxWidth) || (pic_height > maxHeight))
|
||||||
|
g_PicViewer->rescaleImageDimensions(&pic_width, &pic_height, maxWidth, maxHeight);
|
||||||
|
}
|
||||||
|
|
||||||
if (pic_width == 0 || pic_height == 0)
|
if (pic_width == 0 || pic_height == 0)
|
||||||
printf("CComponentsPicture: %s file: %s, no icon dimensions found! width = %d, height = %d\n", __FUNCTION__, pic_name.c_str(), pic_width, pic_height);
|
printf("CComponentsPicture: %s file: %s, no icon dimensions found! width = %d, height = %d\n", __FUNCTION__, pic_name.c_str(), pic_width, pic_height);
|
||||||
|
|
||||||
pic_x += fr_thickness;
|
pic_x += fr_thickness;
|
||||||
pic_y += fr_thickness;
|
pic_y += fr_thickness;
|
||||||
|
|
||||||
if (pic_height>0 && pic_width>0){
|
if (pic_height>0 && pic_width>0){
|
||||||
if (pic_align & CC_ALIGN_LEFT)
|
if (pic_align & CC_ALIGN_LEFT)
|
||||||
pic_x = x+fr_thickness;
|
pic_x = x+fr_thickness;
|
||||||
@@ -760,8 +791,10 @@ void CComponentsPicture::paint(bool do_save_bg)
|
|||||||
paintInit(do_save_bg);
|
paintInit(do_save_bg);
|
||||||
|
|
||||||
if (do_paint){
|
if (do_paint){
|
||||||
pic_painted = frameBuffer->paintIcon(pic_name, pic_x, pic_y, 0, pic_offset, pic_paint, pic_paintBg, col_body);
|
if (picMode == CC_PIC_ICON)
|
||||||
|
pic_painted = frameBuffer->paintIcon(pic_name, pic_x, pic_y, 0, pic_offset, pic_paint, pic_paintBg, col_body);
|
||||||
|
else
|
||||||
|
pic_painted = g_PicViewer->DisplayImage(pic_name, pic_x, pic_y, pic_width, pic_height);
|
||||||
do_paint = false;
|
do_paint = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user