[DEV] change default opening of image

This commit is contained in:
Edouard DUPIN 2015-11-06 22:31:08 +01:00
parent 92eec7385d
commit f33428c251
6 changed files with 35 additions and 13 deletions

View File

@ -12,6 +12,8 @@
#undef __class__ #undef __class__
#define __class__ "ewol::compositing::Image" #define __class__ "ewol::compositing::Image"
const int32_t ewol::compositing::Image::sizeAuto(0);
ewol::compositing::Image::Image(const std::string& _imageName, ewol::compositing::Image::Image(const std::string& _imageName,
bool _df, bool _df,
int32_t _size) : int32_t _size) :

View File

@ -18,6 +18,8 @@
namespace ewol { namespace ewol {
namespace compositing { namespace compositing {
class Image : public ewol::Compositing { class Image : public ewol::Compositing {
public:
static const int32_t sizeAuto;
private: private:
std::string m_filename; std::string m_filename;
ivec2 m_requestSize; ivec2 m_requestSize;
@ -56,7 +58,7 @@ namespace ewol {
*/ */
Image(const std::string& _imageName="", Image(const std::string& _imageName="",
bool _df=false, bool _df=false,
int32_t _size=32); int32_t _size=ewol::compositing::Image::sizeAuto);
/** /**
* @brief generic destructor * @brief generic destructor
*/ */

View File

@ -21,9 +21,11 @@ namespace ewol {
public: public:
Sprite(const std::string& _imageName, Sprite(const std::string& _imageName,
const ivec2& _nbSprite, const ivec2& _nbSprite,
int32_t _size=32); int32_t _size=ewol::compositing::Image::sizeAuto);
virtual ~Sprite() {}; virtual ~Sprite() {};
void printSprite(const ivec2& _spriteID, const vec2& _size) { printSprite(_spriteID, vec3(_size.x(), _size.y(),0)); }; void printSprite(const ivec2& _spriteID, const vec2& _size) {
printSprite(_spriteID, vec3(_size.x(), _size.y(),0));
};
void printSprite(const ivec2& _spriteID, const vec3& _size); void printSprite(const ivec2& _spriteID, const vec3& _size);
}; };
}; };

View File

@ -17,6 +17,9 @@
#undef __class__ #undef __class__
#define __class__ "resource::TextureFile" #define __class__ "resource::TextureFile"
const ivec2 ewol::resource::TextureFile::sizeAuto(-1,-1);
const ivec2 ewol::resource::TextureFile::sizeDefault(0,0);
ewol::resource::TextureFile::TextureFile() { ewol::resource::TextureFile::TextureFile() {
addResourceType("ewol::resource::Image"); addResourceType("ewol::resource::Image");
@ -65,8 +68,8 @@ static int32_t nextP2(int32_t _value) {
std::shared_ptr<ewol::resource::TextureFile> ewol::resource::TextureFile::create(const std::string& _filename, ivec2 _size) { std::shared_ptr<ewol::resource::TextureFile> ewol::resource::TextureFile::create(const std::string& _filename, ivec2 _size, ivec2 _sizeRegister) {
EWOL_VERBOSE("KEEP: TextureFile: '" << _filename << "' size=" << _size); EWOL_VERBOSE("KEEP: TextureFile: '" << _filename << "' size=" << _size << " sizeRegister=" << _sizeRegister);
if (_filename == "") { if (_filename == "") {
std::shared_ptr<ewol::resource::TextureFile> object(new ewol::resource::TextureFile()); std::shared_ptr<ewol::resource::TextureFile> object(new ewol::resource::TextureFile());
if (nullptr == object) { if (nullptr == object) {
@ -86,8 +89,8 @@ std::shared_ptr<ewol::resource::TextureFile> ewol::resource::TextureFile::create
//EWOL_ERROR("Error Request the image size.y() =0 ???"); //EWOL_ERROR("Error Request the image size.y() =0 ???");
} }
std::string TmpFilename = _filename; std::string TmpFilename = _filename;
if (false == etk::end_with(_filename, ".svg") ) { if (etk::end_with(_filename, ".svg") == false) {
_size = ivec2(-1,-1); _size = ewol::resource::TextureFile::sizeAuto;
} }
#ifdef __TARGET_OS__MacOs #ifdef __TARGET_OS__MacOs
EWOL_ERROR("TODO : remove this strange hack"); EWOL_ERROR("TODO : remove this strange hack");
@ -98,10 +101,14 @@ std::shared_ptr<ewol::resource::TextureFile> ewol::resource::TextureFile::create
#ifdef __TARGET_OS__Android #ifdef __TARGET_OS__Android
_size.setValue(nextP2(_size.x()), nextP2(_size.y())); _size.setValue(nextP2(_size.x()), nextP2(_size.y()));
#endif #endif
TmpFilename += ":"; if (_sizeRegister != ewol::resource::TextureFile::sizeAuto) {
TmpFilename += etk::to_string(_size.x()); if (_sizeRegister != ewol::resource::TextureFile::sizeDefault) {
TmpFilename += "x"; TmpFilename += ":";
TmpFilename += etk::to_string(_size.y()); TmpFilename += etk::to_string(_size.x());
TmpFilename += "x";
TmpFilename += etk::to_string(_size.y());
}
}
} }
EWOL_VERBOSE("KEEP: TextureFile: '" << TmpFilename << "' new size=" << _size); EWOL_VERBOSE("KEEP: TextureFile: '" << TmpFilename << "' new size=" << _size);

View File

@ -5,6 +5,7 @@
* *
* @license APACHE v2.0 (see license file) * @license APACHE v2.0 (see license file)
*/ */
// TODO : Change tis file name ...
#ifndef __EWOL_TEXTURE_FILE_H__ #ifndef __EWOL_TEXTURE_FILE_H__
#define __EWOL_TEXTURE_FILE_H__ #define __EWOL_TEXTURE_FILE_H__
@ -14,9 +15,14 @@
#include <egami/Image.h> #include <egami/Image.h>
#include <ewol/resource/Texture.h> #include <ewol/resource/Texture.h>
namespace ewol { namespace ewol {
namespace resource { namespace resource {
class TextureFile : public ewol::resource::Texture { class TextureFile : public ewol::resource::Texture {
public:
static const ivec2 sizeAuto;
static const ivec2 sizeDefault;
private: private:
vec2 m_realImageSize; vec2 m_realImageSize;
protected: protected:
@ -35,9 +41,12 @@ namespace ewol {
* @note Never free this pointer by your own... * @note Never free this pointer by your own...
* @param[in] _filename Name of the image file. * @param[in] _filename Name of the image file.
* @param[in] _requested size of the image (usefull when loading .svg to automatic rescale) * @param[in] _requested size of the image (usefull when loading .svg to automatic rescale)
* @param[in] _sizeRegister size register in named (When you preaload the images the size write here will be )
* @return pointer on the resource or nullptr if an error occured. * @return pointer on the resource or nullptr if an error occured.
*/ */
static std::shared_ptr<ewol::resource::TextureFile> create(const std::string& _filename, ivec2 _size=ivec2(-1,-1)); static std::shared_ptr<ewol::resource::TextureFile> create(const std::string& _filename,
ivec2 _size=ewol::resource::TextureFile::sizeAuto,
ivec2 _sizeRegister=ewol::resource::TextureFile::sizeAuto);
}; };
}; };
}; };

View File

@ -64,7 +64,7 @@ bool ewol::resource::Texture::updateContext() {
// Request a new texture at openGl : // Request a new texture at openGl :
glGenTextures(1, &m_texId); glGenTextures(1, &m_texId);
} }
EWOL_ERROR("plop : load the image:" << m_name); EWOL_VERBOSE("load the image:" << m_name);
// in all case we set the texture properties : // in all case we set the texture properties :
// TODO : check error ??? // TODO : check error ???
glBindTexture(GL_TEXTURE_2D, m_texId); glBindTexture(GL_TEXTURE_2D, m_texId);