[DEBUG] many correction on image display ==> need to work again on it

This commit is contained in:
Edouard DUPIN 2016-12-20 21:45:47 +01:00
parent c3a5f9ae64
commit 54f4040a8d
7 changed files with 53 additions and 37 deletions

View File

@ -52,7 +52,7 @@ ewol::compositing::Image::~Image() {
}
void ewol::compositing::Image::loadProgram() {
// get the shader resource :
// get the shader resource:
m_GLPosition = 0;
m_GLprogram.reset();
if (m_distanceFieldMode == true) {
@ -165,8 +165,17 @@ void ewol::compositing::Image::print(const vec2& _size) {
}
void ewol::compositing::Image::printPart(const vec2& _size,
const vec2& _sourcePosStart,
const vec2& _sourcePosStop) {
vec2 _sourcePosStart,
vec2 _sourcePosStop) {
if (m_resource == nullptr) {
return;
}
vec2 openGLSize = vec2(m_resource->getOpenGlSize().x(), m_resource->getOpenGlSize().y());
vec2 usefullSize = m_resource->getUsableSize();
vec2 ratio = usefullSize/openGLSize;
_sourcePosStart *= ratio;
_sourcePosStop *= ratio;
//EWOL_ERROR("Debug image " << m_filename << " ==> " << m_position << " " << _size << " " << _sourcePosStart << " " << _sourcePosStop);
if (m_angle == 0.0f) {
vec3 point = m_position;

View File

@ -151,8 +151,8 @@ namespace ewol {
* @param[in] _sourcePosStop Stop position in the image [0..1] (can be bigger but this repeate the image).
*/
void printPart(const vec2& _size,
const vec2& _sourcePosStart,
const vec2& _sourcePosStop);
vec2 _sourcePosStart,
vec2 _sourcePosStop);
/**
* @brief change the image Source == > can not be done to display 2 images at the same time ...
* @param[in] _newFile New file of the Image

View File

@ -10,10 +10,29 @@
#include <gale/resource/Manager.hpp>
#include <ewol/resource/Image.hpp>
#include <ewol/resource/Texture.hpp>
#include <thread>
const ivec2 ewol::resource::TextureFile::sizeAuto(-1,-1);
const ivec2 ewol::resource::TextureFile::sizeDefault(0,0);
/**
* @brief get the next power 2 if the input
* @param[in] _value Value that we want the next power of 2
* @return result value
*/
static int32_t nextP2(int32_t _value) {
int32_t val=1;
for (int32_t iii=1; iii<31; iii++) {
if (_value <= val) {
return val;
}
val *=2;
}
EWOL_CRITICAL("impossible CASE.... request P2 of " << _value);
return val;
}
ewol::resource::TextureFile::TextureFile() {
addResourceType("ewol::resource::Image");
@ -35,6 +54,12 @@ void ewol::resource::TextureFile::init(std::string _genName, const std::string&
//egami::store(m_data, "tmpResult.bmp");
ivec2 tmp = m_data.getSize();
m_realImageSize = vec2(tmp.x(), tmp.y());
vec2 compatibilityHWSize = vec2(nextP2(tmp.x()), nextP2(tmp.y()));
if (m_realImageSize != compatibilityHWSize) {
EWOL_ERROR("RESIZE Image for HArwareCompatibility:" << m_realImageSize << " => " << compatibilityHWSize);
m_data.resize(ivec2(compatibilityHWSize.x(),compatibilityHWSize.y()));
}
m_endPointSize = m_realImageSize;
#ifdef GENERATE_DISTANCE_FIELD_MODE
//egami::generateDistanceFieldFile(_tmpFilename, std::string(_tmpFilename, 0, _tmpFilename.size()-4) + ".bmp");
egami::generateDistanceFieldFile(_tmpFilename, std::string(_tmpFilename, 0, _tmpFilename.size()-4) + ".edf");
@ -42,30 +67,6 @@ void ewol::resource::TextureFile::init(std::string _genName, const std::string&
flush();
}
#if defined(__TARGET_OS__Android) \
|| defined(__TARGET_OS__MacOs) \
|| defined(__TARGET_OS__IOs)
/**
* @brief get the next power 2 if the input
* @param[in] _value Value that we want the next power of 2
* @return result value
*/
static int32_t nextP2(int32_t _value) {
int32_t val=1;
for (int32_t iii=1; iii<31; iii++) {
if (_value <= val) {
return val;
}
val *=2;
}
EWOL_CRITICAL("impossible CASE.... request P2 of " << _value);
return val;
}
#endif
ememory::SharedPtr<ewol::resource::TextureFile> ewol::resource::TextureFile::create(const std::string& _filename, ivec2 _size, ivec2 _sizeRegister) {
EWOL_VERBOSE("KEEP: TextureFile: '" << _filename << "' size=" << _size << " sizeRegister=" << _sizeRegister);
if (_filename == "") {
@ -92,11 +93,7 @@ ememory::SharedPtr<ewol::resource::TextureFile> ewol::resource::TextureFile::cre
}
if (_size.x()>0 && _size.y()>0) {
EWOL_VERBOSE(" == > specific size : " << _size);
#if defined(__TARGET_OS__Android) \
|| defined(__TARGET_OS__MacOs) \
|| defined(__TARGET_OS__IOs)
_size.setValue(nextP2(_size.x()), nextP2(_size.y()));
#endif
_size.setValue(nextP2(_size.x()), nextP2(_size.y()));
if (_sizeRegister != ewol::resource::TextureFile::sizeAuto) {
if (_sizeRegister != ewol::resource::TextureFile::sizeDefault) {
tmpFilename += ":";

View File

@ -31,7 +31,7 @@ namespace ewol {
virtual ~Texture();
public:
// you must set the size here, because it will be set in multiple of pow(2)
void setImageSize(ivec2 newSize);
void setImageSize(ivec2 _newSize);
// get the reference on this image to draw nomething on it ...
inline egami::Image& get() {
return m_data;
@ -44,6 +44,9 @@ namespace ewol {
const ivec2& getOpenGlSize() const {
return m_data.getSize();
};
const vec2& getUsableSize() const {
return m_endPointSize;
};
uint32_t getRendererId() const {
return m_texId;
};

View File

@ -49,7 +49,7 @@ namespace ewol {
int32_t m_colorIdCursor; //!< color property of the text cursor
int32_t m_colorIdSelection; //!< color property of the text selection
ewol::compositing::Text m_text; //!< text display m_text
public:
protected:
/**
* @brief Contuctor
* @param[in] _newData The USting that might be set in the Entry box (no event generation!!)

View File

@ -30,11 +30,17 @@ ewol::widget::Image::Image() :
m_colorId = m_colorProperty->request("foreground");
}
}
ewol::widget::Image::~Image() {
}
void ewol::widget::Image::init() {
ewol::Widget::init();
if (*propertySource != "") {
onChangePropertySource();
}
}
void ewol::widget::Image::set(const std::string& _file, const gale::Dimension& _border) {
EWOL_VERBOSE("Set Image : " << _file << " border=" << _border);
propertyBorder.set(_border);

View File

@ -43,6 +43,7 @@ namespace ewol {
* @brief
*/
Image();
void init() override;
public:
DECLARE_WIDGET_FACTORY(Image, "Image");
/**