[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__
#define __class__ "ewol::compositing::Image"
const int32_t ewol::compositing::Image::sizeAuto(0);
ewol::compositing::Image::Image(const std::string& _imageName,
bool _df,
int32_t _size) :

View File

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

View File

@ -21,9 +21,11 @@ namespace ewol {
public:
Sprite(const std::string& _imageName,
const ivec2& _nbSprite,
int32_t _size=32);
int32_t _size=ewol::compositing::Image::sizeAuto);
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);
};
};

View File

@ -17,6 +17,9 @@
#undef __class__
#define __class__ "resource::TextureFile"
const ivec2 ewol::resource::TextureFile::sizeAuto(-1,-1);
const ivec2 ewol::resource::TextureFile::sizeDefault(0,0);
ewol::resource::TextureFile::TextureFile() {
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) {
EWOL_VERBOSE("KEEP: TextureFile: '" << _filename << "' size=" << _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 << " sizeRegister=" << _sizeRegister);
if (_filename == "") {
std::shared_ptr<ewol::resource::TextureFile> object(new ewol::resource::TextureFile());
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 ???");
}
std::string TmpFilename = _filename;
if (false == etk::end_with(_filename, ".svg") ) {
_size = ivec2(-1,-1);
if (etk::end_with(_filename, ".svg") == false) {
_size = ewol::resource::TextureFile::sizeAuto;
}
#ifdef __TARGET_OS__MacOs
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
_size.setValue(nextP2(_size.x()), nextP2(_size.y()));
#endif
TmpFilename += ":";
TmpFilename += etk::to_string(_size.x());
TmpFilename += "x";
TmpFilename += etk::to_string(_size.y());
if (_sizeRegister != ewol::resource::TextureFile::sizeAuto) {
if (_sizeRegister != ewol::resource::TextureFile::sizeDefault) {
TmpFilename += ":";
TmpFilename += etk::to_string(_size.x());
TmpFilename += "x";
TmpFilename += etk::to_string(_size.y());
}
}
}
EWOL_VERBOSE("KEEP: TextureFile: '" << TmpFilename << "' new size=" << _size);

View File

@ -5,6 +5,7 @@
*
* @license APACHE v2.0 (see license file)
*/
// TODO : Change tis file name ...
#ifndef __EWOL_TEXTURE_FILE_H__
#define __EWOL_TEXTURE_FILE_H__
@ -14,9 +15,14 @@
#include <egami/Image.h>
#include <ewol/resource/Texture.h>
namespace ewol {
namespace resource {
class TextureFile : public ewol::resource::Texture {
public:
static const ivec2 sizeAuto;
static const ivec2 sizeDefault;
private:
vec2 m_realImageSize;
protected:
@ -35,9 +41,12 @@ namespace ewol {
* @note Never free this pointer by your own...
* @param[in] _filename Name of the image file.
* @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.
*/
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 :
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 :
// TODO : check error ???
glBindTexture(GL_TEXTURE_2D, m_texId);