[DEV] integarate std x11
This commit is contained in:
parent
01cf75fc9c
commit
35a6730533
@ -13,7 +13,7 @@ egami::Image::Image(const ivec2& _size) :
|
|||||||
// basic element :
|
// basic element :
|
||||||
etk::Color<> tmpBg(0,0,0,0);
|
etk::Color<> tmpBg(0,0,0,0);
|
||||||
// preallocate data with a basic bg elements :
|
// preallocate data with a basic bg elements :
|
||||||
m_data.reSize(m_size.x()*m_size.y(), tmpBg);
|
m_data.resize(m_size.x()*m_size.y(), tmpBg);
|
||||||
if ((uint32_t)m_size.x()*m_size.y() > m_data.size()) {
|
if ((uint32_t)m_size.x()*m_size.y() > m_data.size()) {
|
||||||
TK_ERROR("Allocation of data buffer in error");
|
TK_ERROR("Allocation of data buffer in error");
|
||||||
return;
|
return;
|
||||||
@ -22,7 +22,7 @@ egami::Image::Image(const ivec2& _size) :
|
|||||||
|
|
||||||
void egami::Image::resize(const ivec2& _size, const etk::Color<>& _color) {
|
void egami::Image::resize(const ivec2& _size, const etk::Color<>& _color) {
|
||||||
m_size=_size;
|
m_size=_size;
|
||||||
m_data.reSize(m_size.x()*m_size.y(), _color);
|
m_data.resize(m_size.x()*m_size.y(), _color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void egami::Image::resize(const ivec2& _size, const ivec2& _startPos) {
|
void egami::Image::resize(const ivec2& _size, const ivec2& _startPos) {
|
||||||
@ -34,7 +34,7 @@ void egami::Image::resize(const ivec2& _size, const ivec2& _startPos) {
|
|||||||
egami::Image tmpImage(*this);
|
egami::Image tmpImage(*this);
|
||||||
m_size=_size;
|
m_size=_size;
|
||||||
etk::Color<> tmpBg(0,0,0,0);
|
etk::Color<> tmpBg(0,0,0,0);
|
||||||
m_data.reSize(m_size.x()*m_size.y(), tmpBg);
|
m_data.resize(m_size.x()*m_size.y(), tmpBg);
|
||||||
for (int32_t jjj=0; jjj<m_size.y(); jjj++) {
|
for (int32_t jjj=0; jjj<m_size.y(); jjj++) {
|
||||||
for (int32_t iii=0; iii<m_size.y(); iii++) {
|
for (int32_t iii=0; iii<m_size.y(); iii++) {
|
||||||
ivec2 tmppos(iii,jjj);
|
ivec2 tmppos(iii,jjj);
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#define __EGAMI_IMAGE_H__
|
#define __EGAMI_IMAGE_H__
|
||||||
|
|
||||||
#include <etk/types.h>
|
#include <etk/types.h>
|
||||||
#include <etk/Vector.h>
|
#include <vector>
|
||||||
#include <etk/math/Vector2D.h>
|
#include <etk/math/Vector2D.h>
|
||||||
#include <etk/Color.h>
|
#include <etk/Color.h>
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ namespace egami {
|
|||||||
class Image {
|
class Image {
|
||||||
private:
|
private:
|
||||||
ivec2 m_size;
|
ivec2 m_size;
|
||||||
etk::Vector<etk::Color<> > m_data;
|
std::vector<etk::Color<> > m_data;
|
||||||
public:
|
public:
|
||||||
// constructor :
|
// constructor :
|
||||||
Image(const ivec2& _size=ivec2(32,32));
|
Image(const ivec2& _size=ivec2(32,32));
|
||||||
|
@ -13,15 +13,15 @@
|
|||||||
#include <egami/wrapperPNG.h>
|
#include <egami/wrapperPNG.h>
|
||||||
#include <egami/wrapperBMP.h>
|
#include <egami/wrapperBMP.h>
|
||||||
|
|
||||||
bool egami::scalable(const etk::UString& _fileName) {
|
bool egami::scalable(const std::string& _fileName) {
|
||||||
if (true == _fileName.endWith(".svg") ) {
|
if (true == _fileName.endWith(".svg") ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool egami::load(egami::Image& _output, const etk::UString& _fileName, const ivec2& _size) {
|
bool egami::load(egami::Image& _output, const std::string& _fileName, const ivec2& _size) {
|
||||||
etk::UString tmpName = _fileName.toLower();
|
std::string tmpName = _fileName.toLower();
|
||||||
// select the corect Loader :
|
// select the corect Loader :
|
||||||
if (true == tmpName.endWith(".bmp") ) {
|
if (true == tmpName.endWith(".bmp") ) {
|
||||||
if (false == egami::loadBMP(_fileName, _output)) {
|
if (false == egami::loadBMP(_fileName, _output)) {
|
||||||
@ -45,8 +45,8 @@ bool egami::load(egami::Image& _output, const etk::UString& _fileName, const ive
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool egami::store(const egami::Image& _input, const etk::UString& _fileName) {
|
bool egami::store(const egami::Image& _input, const std::string& _fileName) {
|
||||||
etk::UString tmpName = _fileName.toLower();
|
std::string tmpName = _fileName.toLower();
|
||||||
// select the corect Loader :
|
// select the corect Loader :
|
||||||
if (true == tmpName.endWith(".bmp") ) {
|
if (true == tmpName.endWith(".bmp") ) {
|
||||||
if (false == egami::storeBMP(_fileName, _input)) {
|
if (false == egami::storeBMP(_fileName, _input)) {
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#define __EGAMI_H__
|
#define __EGAMI_H__
|
||||||
|
|
||||||
#include <etk/types.h>
|
#include <etk/types.h>
|
||||||
#include <etk/Vector.h>
|
#include <vector>
|
||||||
#include <etk/math/Vector2D.h>
|
#include <etk/math/Vector2D.h>
|
||||||
#include <etk/Color.h>
|
#include <etk/Color.h>
|
||||||
#include <egami/Image.h>
|
#include <egami/Image.h>
|
||||||
@ -24,20 +24,20 @@ namespace egami
|
|||||||
* @param[in] _size Dimention of the file when resizable (SVG).
|
* @param[in] _size Dimention of the file when resizable (SVG).
|
||||||
* @return true if the file is corectly loaded, false otherwise.
|
* @return true if the file is corectly loaded, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool load(egami::Image& _output, const etk::UString& _fileName, const ivec2& _size=ivec2(-1,-1) );
|
bool load(egami::Image& _output, const std::string& _fileName, const ivec2& _size=ivec2(-1,-1) );
|
||||||
/**
|
/**
|
||||||
* @brief Save an image in a file.
|
* @brief Save an image in a file.
|
||||||
* @param[in] _input Data of the image.
|
* @param[in] _input Data of the image.
|
||||||
* @param[in] _fileName Name of the file.
|
* @param[in] _fileName Name of the file.
|
||||||
* @return true if the file is corectly Stored, false otherwise
|
* @return true if the file is corectly Stored, false otherwise
|
||||||
*/
|
*/
|
||||||
bool store(const egami::Image& _input, const etk::UString& _fileName);
|
bool store(const egami::Image& _input, const std::string& _fileName);
|
||||||
/**
|
/**
|
||||||
* @brief know if a file can have multiple size definition.
|
* @brief know if a file can have multiple size definition.
|
||||||
* @param[in] _fileName Name of the file.
|
* @param[in] _fileName Name of the file.
|
||||||
* @return true if the format is scalable.
|
* @return true if the format is scalable.
|
||||||
*/
|
*/
|
||||||
bool scalable(const etk::UString& _fileName);
|
bool scalable(const std::string& _fileName);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,7 +45,7 @@ enum modeBitmap {
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "wrapperBMP"
|
#define __class__ "wrapperBMP"
|
||||||
|
|
||||||
bool egami::loadBMP(const etk::UString& _inputFile, egami::Image& _ouputImage) {
|
bool egami::loadBMP(const std::string& _inputFile, egami::Image& _ouputImage) {
|
||||||
enum modeBitmap m_dataMode = BITS_16_R5G6B5;
|
enum modeBitmap m_dataMode = BITS_16_R5G6B5;
|
||||||
int32_t m_width = 0;
|
int32_t m_width = 0;
|
||||||
int32_t m_height = 0;
|
int32_t m_height = 0;
|
||||||
@ -215,7 +215,7 @@ bool egami::loadBMP(const etk::UString& _inputFile, egami::Image& _ouputImage) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool egami::storeBMP(const etk::UString& _fileName, const egami::Image& _inputImage) {
|
bool egami::storeBMP(const std::string& _fileName, const egami::Image& _inputImage) {
|
||||||
struct bitmapFileHeader m_FileHeader;
|
struct bitmapFileHeader m_FileHeader;
|
||||||
struct bitmapInfoHeader m_InfoHeader;
|
struct bitmapInfoHeader m_InfoHeader;
|
||||||
|
|
||||||
|
@ -19,14 +19,14 @@ namespace egami
|
|||||||
* @param[out] _ouputImage Read data.
|
* @param[out] _ouputImage Read data.
|
||||||
* @return true if all is done correctly, false otherwise.
|
* @return true if all is done correctly, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool loadBMP(const etk::UString& _fileName, egami::Image& _ouputImage);
|
bool loadBMP(const std::string& _fileName, egami::Image& _ouputImage);
|
||||||
/**
|
/**
|
||||||
* @breif Store a bmp file in the image.
|
* @breif Store a bmp file in the image.
|
||||||
* @param[in] _fileName Name of the file.
|
* @param[in] _fileName Name of the file.
|
||||||
* @param[in] _inputImage write data.
|
* @param[in] _inputImage write data.
|
||||||
* @return true if all is done correctly, false otherwise.
|
* @return true if all is done correctly, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool storeBMP(const etk::UString& _fileName, const egami::Image& _inputImage);
|
bool storeBMP(const std::string& _fileName, const egami::Image& _inputImage);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,7 +42,7 @@ static void localFlushData(png_structp png_ptr)
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool egami::loadPNG(const etk::UString& _inputFile, egami::Image& _ouputImage) {
|
bool egami::loadPNG(const std::string& _inputFile, egami::Image& _ouputImage) {
|
||||||
etk::FSNode fileName(_inputFile);
|
etk::FSNode fileName(_inputFile);
|
||||||
|
|
||||||
if (false == fileName.exist()) {
|
if (false == fileName.exist()) {
|
||||||
|
@ -19,7 +19,7 @@ namespace egami
|
|||||||
* @param[out] _ouputImage Read data.
|
* @param[out] _ouputImage Read data.
|
||||||
* @return true if all is done correctly, false otherwise.
|
* @return true if all is done correctly, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool loadPNG(const etk::UString& _fileName, egami::Image& _ouputImage);
|
bool loadPNG(const std::string& _fileName, egami::Image& _ouputImage);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#define __class__ "wrapperSVG"
|
#define __class__ "wrapperSVG"
|
||||||
|
|
||||||
|
|
||||||
bool egami::loadSVG(const etk::UString& _fileName, egami::Image& _ouputImage, const ivec2& _size) {
|
bool egami::loadSVG(const std::string& _fileName, egami::Image& _ouputImage, const ivec2& _size) {
|
||||||
esvg::Document m_element(_fileName);
|
esvg::Document m_element(_fileName);
|
||||||
if (false == m_element.isLoadOk()) {
|
if (false == m_element.isLoadOk()) {
|
||||||
EGAMI_ERROR("Error to load SVG file " << _fileName );
|
EGAMI_ERROR("Error to load SVG file " << _fileName );
|
||||||
|
@ -20,7 +20,7 @@ namespace egami
|
|||||||
* @param[in] _size size of the output image.
|
* @param[in] _size size of the output image.
|
||||||
* @return true if all is done correctly, false otherwise.
|
* @return true if all is done correctly, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool loadSVG(const etk::UString& _fileName, egami::Image& _ouputImage, const ivec2& _size=ivec2(-1,-1));
|
bool loadSVG(const std::string& _fileName, egami::Image& _ouputImage, const ivec2& _size=ivec2(-1,-1));
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user