From 0aae491cccad8d5efb424c4b051f427ea4e3f455 Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Tue, 25 Apr 2017 11:21:44 +0200 Subject: [PATCH] CComponentsPicture: add methode to get real image size --- src/gui/components/cc_item_picture.cpp | 22 +++++++++++++++------- src/gui/components/cc_item_picture.h | 9 +++++---- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/gui/components/cc_item_picture.cpp b/src/gui/components/cc_item_picture.cpp index 91841c071..c776dfcb6 100644 --- a/src/gui/components/cc_item_picture.cpp +++ b/src/gui/components/cc_item_picture.cpp @@ -76,6 +76,7 @@ void CComponentsPicture::init( const int &x_pos, const int &y_pos, const int &w, y = y_old = y_pos; width = width_old = dx = dxc = w; height = height_old = dy = dyc = h; + dx_orig = dy_orig = 0; pic_name = pic_name_old = image_name; shadow = shadow_mode; shadow_w = OFFSET_SHADOW; @@ -201,6 +202,9 @@ void CComponentsPicture::initCCItem() if (height == 0) height = dy_tmp; } + dx_orig = width; + dy_orig = height; + /* leave init methode here if we in no scale mode * otherwise goto next step! */ @@ -211,8 +215,12 @@ void CComponentsPicture::initCCItem() * check internal dimension values (dx/dy) and ensure that values are >0 * real image size */ - if ((dx != width || dy != height) || (dx == 0 || dy == 0)) - g_PicViewer->getSize(pic_name.c_str(), &dx, &dy); + g_PicViewer->getSize(pic_name.c_str(), &dx_orig, &dy_orig); + if ((dx != width || dy != height) || (dx == 0 || dy == 0)){ + dx = dx_orig; + dy = dy_orig; + //g_PicViewer->getSize(pic_name.c_str(), &dx, &dy); + } } /* on next step check item dimensions (width/height) for 0 values @@ -269,11 +277,11 @@ void CComponentsPicture::initPosition(int *x_position, int *y_position) } -// void CComponentsPicture::getSize(int* width_image, int *height_image) -// { -// *width_image = width; -// *height_image = height; -// } +void CComponentsPicture::getRealSize(int* dx_original, int *dy_original) +{ + *dx_original = dx_orig; + *dy_original = dy_orig; +} int CComponentsPicture::getWidth() { diff --git a/src/gui/components/cc_item_picture.h b/src/gui/components/cc_item_picture.h index 7bf8953d0..ef8204d55 100644 --- a/src/gui/components/cc_item_picture.h +++ b/src/gui/components/cc_item_picture.h @@ -54,9 +54,10 @@ class CComponentsPicture : public CComponentsItem ///screen cache content for painted image fb_pixel_t *image_cache; - ///current original image dimensions + ///current image dimensions int dx, dy; - + ///original image dimensions + int dx_orig, dy_orig; ///cached image dimensions int dxc, dyc; @@ -146,8 +147,8 @@ class CComponentsPicture : public CComponentsItem ///returns current assigned image name std::string getPictureName(){return pic_name;} -// ///handle image size -// void getSize(int* width_image, int *height_image); + ///get original image size + void getRealSize(int* dx_orig, int *dy_orig); ///return width of item int getWidth(); ///return height of item