* CComponents::CComponentsPicture: Add the processing and scaling images

This commit is contained in:
micha-bbg
2012-08-24 18:21:47 +02:00
committed by Thilo Graf
parent e6eb91f706
commit 61ed9d4862
2 changed files with 56 additions and 10 deletions

View File

@@ -89,6 +89,12 @@ enum
CC_ALIGN_VER_CENTER = 16
};
enum
{
CC_PIC_ICON,
CC_PIC_IMAGE
};
#define CC_WIDTH_MIN 16
#define CC_HEIGHT_MIN 16
#define CC_SHADOW_ON true
@@ -172,11 +178,18 @@ class CComponentsPicture : public CComponentsContainer
unsigned char pic_offset;
bool pic_paint, pic_paintBg, pic_painted, do_paint;
int pic_align, pic_x, pic_y, pic_width, pic_height;
int maxWidth, maxHeight, picMode;
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:
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);
void setPictureOffset(const unsigned char offset){pic_offset = offset;};
void setPicturePaint(bool paint_p){pic_paint = paint_p;};

View File

@@ -31,10 +31,12 @@
#include <global.h>
#include <neutrino.h>
#include "cc.h"
#include <driver/pictureviewer/pictureviewer.h>
#include <video.h>
extern cVideo * videoDecoder;
extern CPictureViewer * g_PicViewer;
using namespace std;
@@ -669,7 +671,33 @@ void CComponentsPIP::hide(bool no_restore)
//-------------------------------------------------------------------------------------------------------
//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)
{
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
@@ -699,11 +727,8 @@ CComponentsPicture::CComponentsPicture( int x_pos, int y_pos, const string& pict
firstPaint = true;
v_fbdata.clear();
bgMode = CC_BGMODE_PERMANENT;
initVarPicture();
}
void CComponentsPicture::setPicture(const std::string& picture_name)
{
pic_name = picture_name;
@@ -724,7 +749,13 @@ void CComponentsPicture::initVarPicture()
pic_painted = false;
do_paint = false;
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)
printf("CComponentsPicture: %s file: %s, no icon dimensions found! width = %d, height = %d\n", __FUNCTION__, pic_name.c_str(), pic_width, pic_height);
@@ -760,8 +791,10 @@ void CComponentsPicture::paint(bool do_save_bg)
paintInit(do_save_bg);
if (do_paint){
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;
}
}