[DEV] many correction on read write file
- BMP read write correction RGB order - JPG and PNG correct sens on the image - image private, correct the internal data
BIN
data/read_128x128.bmp
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
data/read_128x128.jpg
Normal file
After Width: | Height: | Size: 6.2 KiB |
BIN
data/read_128x128.png
Normal file
After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 100 KiB |
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
BIN
data/read_228x149.bmp
Normal file
After Width: | Height: | Size: 100 KiB |
@ -149,7 +149,7 @@ void egami::Image::resize(const ivec2& _size, const ivec2& _startPos) {
|
||||
EGAMI_DEBUG("No internal data for image (nullptr)");
|
||||
return;
|
||||
}
|
||||
m_data->resize(_size, _startPos);
|
||||
m_data->resize2(_size, _startPos);
|
||||
}
|
||||
|
||||
void egami::Image::resize(const ivec2& _size, const etk::Color<>& _color, const ivec2& _startPos) {
|
||||
|
@ -57,7 +57,7 @@ namespace egami {
|
||||
virtual void resize(const ivec2& _size, const etk::Color<uint32_t, 1>& _color, const ivec2& _startPos) = 0;
|
||||
virtual void resize(const ivec2& _size, const etk::Color<float, 1>& _color, const ivec2& _startPos) = 0;
|
||||
virtual void resize(const ivec2& _size, const etk::Color<double, 1>& _color, const ivec2& _startPos) = 0;
|
||||
virtual void resize(const ivec2& _size, const ivec2& _startPos) = 0;
|
||||
virtual void resize2(const ivec2& _size, const ivec2& _startPos) = 0;
|
||||
virtual void set(const ivec2& _pos, const etk::Color<>& _newColor) = 0;
|
||||
virtual void set(const ivec2& _pos, const etk::Color<float>& _newColor) = 0;
|
||||
virtual void set(const ivec2& _pos, const etk::Color<uint16_t, 1>& _newColor) = 0;
|
||||
|
@ -14,18 +14,18 @@
|
||||
|
||||
namespace egami {
|
||||
|
||||
template<typename T = etk::Color<>>
|
||||
template<typename EGAMI_TYPE_COLOR = etk::Color<>>
|
||||
class ImageTemplate : public ImagePrivate {
|
||||
private:
|
||||
ivec2 m_size;
|
||||
std::vector<T> m_data;
|
||||
std::vector<EGAMI_TYPE_COLOR> m_data;
|
||||
public:
|
||||
// constructor :
|
||||
ImageTemplate(const ivec2& _size=ivec2(32,32)) :
|
||||
m_size(_size) {
|
||||
// basic element :
|
||||
// basic element:
|
||||
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);
|
||||
if ((uint32_t)m_size.x()*m_size.y() > m_data.size()) {
|
||||
//TK_ERROR("Allocation of data buffer in error");
|
||||
@ -35,7 +35,7 @@ namespace egami {
|
||||
|
||||
// destructor
|
||||
virtual ~ImageTemplate() { };
|
||||
// EWOL internal API for Texture system :
|
||||
// EWOL internal API for Texture system:
|
||||
public:
|
||||
void* getTextureDataPointer() {
|
||||
return &m_data[0];
|
||||
@ -45,60 +45,74 @@ namespace egami {
|
||||
return m_size;
|
||||
};
|
||||
// -----------------------------------------------
|
||||
// -- basic tools :
|
||||
// -- basic tools:
|
||||
// -----------------------------------------------
|
||||
public :
|
||||
void resize__(const ivec2& _size, const ivec2& _startPos=ivec2(0,0)) {
|
||||
void resize2__(const ivec2& _size, const ivec2& _startPos=ivec2(0,0)) {
|
||||
if (_size == m_size) {
|
||||
// same size == > nothing to do ...
|
||||
return;
|
||||
}
|
||||
if ((size_t)(_size.x()*_size.y()) > m_data.size()) {
|
||||
m_data.resize(_size.x()*_size.y());
|
||||
ivec2 oldSize = m_size;
|
||||
m_size = _size;
|
||||
if ((size_t)(m_size.x()*m_size.y()) > m_data.size()) {
|
||||
m_data.resize(m_size.x()*m_size.y());
|
||||
}
|
||||
// grow size :
|
||||
if (_size.x() == m_size.x()) {
|
||||
if (_size.y() < m_size.y()) {
|
||||
if (m_size.x() == oldSize.x()) {
|
||||
if (m_size.y() < oldSize.y()) {
|
||||
// Just remove lines ....
|
||||
} else {
|
||||
// just add lines
|
||||
}
|
||||
} else if (_size.x() < m_size.x()) {
|
||||
if (_size.y() <= m_size.y()) {
|
||||
for (int32_t yyy=0; yyy<_size.y(); ++yyy) {
|
||||
for (int32_t xxx=0; xxx<_size.x(); ++xxx) {
|
||||
m_data[yyy*_size.x()+xxx] = m_data[yyy*m_size.x()+xxx];
|
||||
} else if (m_size.x() < oldSize.x()) {
|
||||
if (m_size.y() <= oldSize.y()) {
|
||||
for (int32_t yyy=0; yyy<m_size.y(); ++yyy) {
|
||||
for (int32_t xxx=0; xxx<m_size.x(); ++xxx) {
|
||||
m_data[yyy*m_size.x()+xxx] = m_data[yyy*oldSize.x()+xxx];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int32_t yyy=m_size.y()-1; yyy>=0; --yyy) {
|
||||
for (int32_t xxx=0; xxx<_size.x(); ++xxx) {
|
||||
m_data[yyy*_size.x()+xxx] = m_data[yyy*m_size.x()+xxx];
|
||||
for (int32_t yyy=oldSize.y()-1; yyy>=0; --yyy) {
|
||||
for (int32_t xxx=0; xxx<m_size.x(); ++xxx) {
|
||||
m_data[yyy*m_size.x()+xxx] = m_data[yyy*oldSize.x()+xxx];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { // (_size.x() > m_size.x())
|
||||
} else { // (m_size.x() > oldSize.x())
|
||||
|
||||
if (_size.y() <= m_size.y()) {
|
||||
for (int32_t yyy=0; yyy<_size.y(); ++yyy) {
|
||||
for (int32_t xxx=0; xxx<m_size.x(); ++xxx) {
|
||||
m_data[yyy*_size.x()+xxx] = m_data[yyy*m_size.x()+xxx];
|
||||
if (m_size.y() <= oldSize.y()) {
|
||||
for (int32_t yyy=0; yyy<m_size.y(); ++yyy) {
|
||||
for (int32_t xxx=0; xxx<oldSize.x(); ++xxx) {
|
||||
m_data[yyy*m_size.x()+xxx] = m_data[yyy*oldSize.x()+xxx];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int32_t yyy=m_size.y()-1; yyy>=0; --yyy) {
|
||||
for (int32_t xxx=0; xxx<m_size.x(); ++xxx) {
|
||||
m_data[yyy*_size.x()+xxx] = m_data[yyy*m_size.x()+xxx];
|
||||
for (int32_t yyy=oldSize.y()-1; yyy>=0; --yyy) {
|
||||
for (int32_t xxx=0; xxx<oldSize.x(); ++xxx) {
|
||||
m_data[yyy*m_size.x()+xxx] = m_data[yyy*oldSize.x()+xxx];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((size_t)(_size.x()*_size.y()) < m_data.size()) {
|
||||
m_data.resize(_size.x()*_size.y());
|
||||
if ((size_t)(m_size.x()*m_size.y()) < m_data.size()) {
|
||||
m_data.resize(m_size.x()*m_size.y());
|
||||
}
|
||||
// Clean all Data outside old range:
|
||||
// basic element:
|
||||
etk::Color<> tmpBg(0,0,0,0);
|
||||
for (int32_t yyy=oldSize.y()-1; yyy<m_size.x(); ++yyy) {
|
||||
for (int32_t xxx=0; xxx<m_size.x(); ++xxx) {
|
||||
set(ivec2(xxx,yyy), tmpBg);
|
||||
}
|
||||
}
|
||||
for (int32_t yyy=0; yyy<m_size.x(); ++yyy) {
|
||||
for (int32_t xxx=oldSize.x()-1; xxx<m_size.x(); ++xxx) {
|
||||
set(ivec2(xxx,yyy), tmpBg);
|
||||
}
|
||||
}
|
||||
m_size = _size;
|
||||
}
|
||||
void resize__(const ivec2& _size, const T& _color) {
|
||||
void resize__(const ivec2& _size, const EGAMI_TYPE_COLOR& _color) {
|
||||
m_size=_size;
|
||||
m_data.resize(m_size.x()*m_size.y(), _color);
|
||||
}
|
||||
@ -122,11 +136,11 @@ namespace egami {
|
||||
resize__(_size, _color);
|
||||
}
|
||||
|
||||
void resize(const ivec2& _size, const ivec2& _startPos) {
|
||||
resize__(_size);
|
||||
void resize2(const ivec2& _size, const ivec2& _startPos) {
|
||||
resize2__(_size, _startPos);
|
||||
}
|
||||
template<typename TYPE_2> void resize(const ivec2& _size, const TYPE_2& _color) {
|
||||
T tmp(_color);
|
||||
template<typename EGAMI_TYPE_COLOR_2> void resize(const ivec2& _size, const EGAMI_TYPE_COLOR_2& _color) {
|
||||
EGAMI_TYPE_COLOR tmp(_color);
|
||||
resize__(_size, tmp);
|
||||
}
|
||||
void set(const ivec2& _pos, const etk::Color<>& _newColor) {
|
||||
@ -157,33 +171,33 @@ namespace egami {
|
||||
int32_t getHeight() const {
|
||||
return m_size.y();
|
||||
};
|
||||
void clearColor(const T& _fill) {
|
||||
void clearColor(const EGAMI_TYPE_COLOR& _fill) {
|
||||
for (int32_t iii=0; iii<m_size.x()*m_size.y(); iii++) {
|
||||
m_data[iii] = _fill;
|
||||
}
|
||||
}
|
||||
void clear() {
|
||||
clearColor(T::emptyColor);
|
||||
clearColor(EGAMI_TYPE_COLOR::emptyColor);
|
||||
}
|
||||
etk::Color<> get(const ivec2& _pos) const {
|
||||
return get__(_pos);
|
||||
}
|
||||
|
||||
const T& get__(const ivec2& _pos) const {
|
||||
static const T errorColor(0x00000000);
|
||||
const EGAMI_TYPE_COLOR& get__(const ivec2& _pos) const {
|
||||
static const EGAMI_TYPE_COLOR errorColor(0x00000000);
|
||||
if( _pos.x()>=0 && _pos.x()<m_size.x()
|
||||
&& _pos.y()>=0 && _pos.y()<m_size.y()) {
|
||||
return m_data[_pos.x()+_pos.y()*m_size.x()];
|
||||
}
|
||||
return errorColor;
|
||||
}
|
||||
void set__(const ivec2& _pos, const T& _newColor) {
|
||||
void set__(const ivec2& _pos, const EGAMI_TYPE_COLOR& _newColor) {
|
||||
if( _pos.x()>=0 && _pos.x()<m_size.x()
|
||||
&& _pos.y()>=0 && _pos.y()<m_size.y()) {
|
||||
m_data[_pos.x()+_pos.y()*m_size.x()] = _newColor;
|
||||
}
|
||||
}
|
||||
void insert(const ivec2& _pos, const ImageTemplate<T>& _input) {
|
||||
void insert(const ivec2& _pos, const ImageTemplate<EGAMI_TYPE_COLOR>& _input) {
|
||||
for(int32_t yyy = 0; yyy < _input.getSize().y() && _pos.y() + yyy < m_size.y(); ++yyy) {
|
||||
for(int32_t xxx = 0; xxx < _input.getSize().x() && _pos.x() + xxx < m_size.x(); ++xxx) {
|
||||
set(ivec2(_pos.x()+xxx, _pos.y()+yyy), _input.get(ivec2(xxx, yyy)) );
|
||||
|
@ -27,8 +27,28 @@ extern "C" {
|
||||
int32_t biSizeImage;
|
||||
int32_t biXPelsPerMeter;
|
||||
int32_t biYPelsPerMeter;
|
||||
int32_t biClrUsed;
|
||||
int32_t biClrImportant;
|
||||
int32_t biPaletteNumber;
|
||||
int32_t biImportantColor;
|
||||
};
|
||||
struct bitmapInfoHeaderExtended {
|
||||
int32_t biSize;
|
||||
int32_t biWidth;
|
||||
int32_t biHeight;
|
||||
int16_t biPlanes;
|
||||
int16_t biBitCount;
|
||||
int32_t biCompression;
|
||||
int32_t biSizeImage;
|
||||
int32_t biXPelsPerMeter;
|
||||
int32_t biYPelsPerMeter;
|
||||
// https://en.wikipedia.org/wiki/BMP_file_format / example 2
|
||||
int32_t biPaletteNumber;
|
||||
int32_t biImportantColor;
|
||||
int32_t biLCSColorSpace; // This is at this position, inspection of "gimp" output ...
|
||||
int32_t biBitMaskRed;
|
||||
int32_t biBitMaskGreen;
|
||||
int32_t biBitMaskBlue;
|
||||
int32_t biBitMaskAlpha;
|
||||
int32_t biUnused[12];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
}
|
||||
@ -59,8 +79,8 @@ static void display(struct bitmapFileHeader _header, struct bitmapInfoHeader _in
|
||||
EGAMI_DEBUG(" biSizeImage =" << _info.biSizeImage << " specifies the size of the image data, in bytes. If there is no compression, it is valid to set this member to zero.");
|
||||
EGAMI_DEBUG(" biXPelsPerMeter=" << _info.biXPelsPerMeter << " specifies the the horizontal pixels per meter on the designated targer device, usually set to zero.");
|
||||
EGAMI_DEBUG(" biYPelsPerMeter=" << _info.biYPelsPerMeter << " specifies the the vertical pixels per meter on the designated targer device, usually set to zero.");
|
||||
EGAMI_DEBUG(" biClrUsed =" << _info.biClrUsed << " speglTexImage2Dcifies the number of colors used in the bitmap, if set to zero the number of colors is calculated using the biBitCount member.");
|
||||
EGAMI_DEBUG(" biClrImportant =" << _info.biClrImportant << " specifies the number of color that are 'important' for the bitmap, if set to zero, all colors are important.");
|
||||
EGAMI_DEBUG(" biClrUsed =" << _info.biPaletteNumber << " Pallet color number.");
|
||||
EGAMI_DEBUG(" biClrImportant =" << _info.biImportantColor << " Important color ID.");
|
||||
/*
|
||||
EGAMI_DEBUG("Bitmap : " << m_width << "x" << m_height);
|
||||
switch(m_dataMode)
|
||||
@ -94,7 +114,9 @@ egami::Image egami::loadBMP(const std::string& _inputFile) {
|
||||
int32_t m_width = 0;
|
||||
int32_t m_height = 0;
|
||||
struct bitmapFileHeader m_FileHeader;
|
||||
bool useExtended = false;
|
||||
struct bitmapInfoHeader m_InfoHeader;
|
||||
struct bitmapInfoHeaderExtended m_InfoHeaderExtended;
|
||||
|
||||
etk::FSNode fileName(_inputFile);
|
||||
// get the fileSize ...
|
||||
@ -116,10 +138,32 @@ egami::Image egami::loadBMP(const std::string& _inputFile) {
|
||||
fileName.fileClose();
|
||||
return out;
|
||||
}
|
||||
if (fileName.fileRead(&m_InfoHeader,sizeof(struct bitmapInfoHeader),1) != 1) {
|
||||
EGAMI_ERROR("error loading file header");
|
||||
fileName.fileClose();
|
||||
return out;
|
||||
if (m_FileHeader.bfOffBits > sizeof(struct bitmapFileHeader) + sizeof(struct bitmapInfoHeader)) {
|
||||
EGAMI_WARNING("Read bitmap in EXTENDED mode ...");
|
||||
if (fileName.fileRead(&m_InfoHeaderExtended,sizeof(struct bitmapInfoHeaderExtended),1) != 1) {
|
||||
EGAMI_ERROR("error loading file header");
|
||||
fileName.fileClose();
|
||||
return out;
|
||||
}
|
||||
useExtended = true;
|
||||
m_InfoHeader.biSize = m_InfoHeaderExtended.biSize;
|
||||
m_InfoHeader.biWidth = m_InfoHeaderExtended.biWidth;
|
||||
m_InfoHeader.biHeight = m_InfoHeaderExtended.biHeight;
|
||||
m_InfoHeader.biHeight = m_InfoHeaderExtended.biHeight;
|
||||
m_InfoHeader.biHeight = m_InfoHeaderExtended.biHeight;
|
||||
m_InfoHeader.biBitCount = m_InfoHeaderExtended.biBitCount;
|
||||
m_InfoHeader.biCompression = m_InfoHeaderExtended.biCompression;
|
||||
m_InfoHeader.biSizeImage = m_InfoHeaderExtended.biSizeImage;
|
||||
m_InfoHeader.biXPelsPerMeter = m_InfoHeaderExtended.biXPelsPerMeter;
|
||||
m_InfoHeader.biYPelsPerMeter = m_InfoHeaderExtended.biYPelsPerMeter;
|
||||
} else {
|
||||
EGAMI_WARNING("Read bitmap in BASIC mode ...");
|
||||
if (fileName.fileRead(&m_InfoHeader,sizeof(struct bitmapInfoHeader),1) != 1) {
|
||||
EGAMI_ERROR("error loading file header");
|
||||
fileName.fileClose();
|
||||
return out;
|
||||
}
|
||||
useExtended = false;
|
||||
}
|
||||
//display(m_FileHeader, m_InfoHeader);
|
||||
//EGAMI_ERROR("plopppppppppppppp " << m_FileHeader.bfOffBits);
|
||||
@ -166,6 +210,7 @@ egami::Image egami::loadBMP(const std::string& _inputFile) {
|
||||
fileName.fileClose();;
|
||||
return out;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> m_data;
|
||||
if(m_InfoHeader.biSizeImage != 0) {
|
||||
m_data.resize(m_InfoHeader.biSizeImage, 0);
|
||||
@ -183,11 +228,11 @@ egami::Image egami::loadBMP(const std::string& _inputFile) {
|
||||
uint16_t * pointer = (uint16_t*)(&m_data[0]);
|
||||
for(int32_t yyy=0; yyy<m_height; yyy++) {
|
||||
for(int32_t xxx=0; xxx<m_width; xxx++) {
|
||||
tmpColor.setR((uint8_t)((*pointer & 0xF800) >> 8));
|
||||
tmpColor.setB((uint8_t)((*pointer & 0xF800) >> 8));
|
||||
tmpColor.setG((uint8_t)((*pointer & 0x07E0) >> 3));
|
||||
tmpColor.setB((uint8_t)(*pointer << 3));
|
||||
tmpColor.setR((uint8_t)(*pointer << 3));
|
||||
tmpColor.setA(0xFF);
|
||||
out.set(ivec2(xxx,yyy), tmpColor);
|
||||
out.set(ivec2(xxx,m_height-yyy-1), tmpColor);
|
||||
pointer++;
|
||||
}
|
||||
}
|
||||
@ -197,11 +242,11 @@ egami::Image egami::loadBMP(const std::string& _inputFile) {
|
||||
uint16_t * pointer = (uint16_t*)(&m_data[0]);
|
||||
for(int32_t yyy=0; yyy<m_height; yyy++) {
|
||||
for(int32_t xxx=0; xxx<m_width; xxx++) {
|
||||
tmpColor.setR((int8_t)((*pointer & 0x7C00) >> 7));
|
||||
tmpColor.setB((int8_t)((*pointer & 0x7C00) >> 7));
|
||||
tmpColor.setG((int8_t)((*pointer & 0x03E0) >> 2));
|
||||
tmpColor.setB((int8_t)(*pointer << 3));
|
||||
tmpColor.setR((int8_t)(*pointer << 3));
|
||||
tmpColor.setA(0xFF);
|
||||
out.set(ivec2(xxx,yyy), tmpColor);
|
||||
out.set(ivec2(xxx,m_height-yyy-1), tmpColor);
|
||||
pointer++;
|
||||
}
|
||||
}
|
||||
@ -220,16 +265,15 @@ egami::Image egami::loadBMP(const std::string& _inputFile) {
|
||||
uint8_t * pointer = (&m_data[0]);
|
||||
for(int32_t yyy=0; yyy<m_height; yyy++) {
|
||||
for(int32_t xxx=0; xxx<m_width; xxx++) {
|
||||
tmpColor.setR(*pointer++);
|
||||
tmpColor.setG(*pointer++);
|
||||
tmpColor.setB(*pointer++);
|
||||
tmpColor.setG(*pointer++);
|
||||
tmpColor.setR(*pointer++);
|
||||
tmpColor.setA(0xFF);
|
||||
out.set(ivec2(xxx,yyy), tmpColor);
|
||||
out.set(ivec2(xxx,m_height-yyy-1), tmpColor);
|
||||
}
|
||||
/*
|
||||
for(int32_t xxx=0; xxx<offset; xxx++) {
|
||||
pointer++;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -238,11 +282,11 @@ egami::Image egami::loadBMP(const std::string& _inputFile) {
|
||||
for(int32_t yyy=0; yyy<m_height; yyy++) {
|
||||
for(int32_t xxx=0; xxx<m_width; xxx++) {
|
||||
pointer++;
|
||||
tmpColor.setR(*pointer++);
|
||||
tmpColor.setG(*pointer++);
|
||||
tmpColor.setB(*pointer++);
|
||||
tmpColor.setG(*pointer++);
|
||||
tmpColor.setR(*pointer++);
|
||||
tmpColor.setA(0xFF);
|
||||
out.set(ivec2(xxx,yyy), tmpColor);
|
||||
out.set(ivec2(xxx,m_height-yyy-1), tmpColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -251,11 +295,11 @@ egami::Image egami::loadBMP(const std::string& _inputFile) {
|
||||
uint8_t * pointer = (&m_data[0]);
|
||||
for(int32_t yyy=0; yyy<m_height; yyy++) {
|
||||
for(int32_t xxx=0; xxx<m_width; xxx++) {
|
||||
tmpColor.setR(*pointer++);
|
||||
tmpColor.setG(*pointer++);
|
||||
tmpColor.setB(*pointer++);
|
||||
tmpColor.setG(*pointer++);
|
||||
tmpColor.setR(*pointer++);
|
||||
tmpColor.setA(*pointer++);
|
||||
out.set(ivec2(xxx,yyy), tmpColor);
|
||||
out.set(ivec2(xxx,m_height-yyy-1), tmpColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -269,14 +313,14 @@ egami::Image egami::loadBMP(const std::string& _inputFile) {
|
||||
|
||||
bool egami::storeBMP(const std::string& _fileName, const egami::Image& _inputImage) {
|
||||
struct bitmapFileHeader m_FileHeader;
|
||||
struct bitmapInfoHeader m_InfoHeader;
|
||||
|
||||
struct bitmapInfoHeaderExtended m_InfoHeader;
|
||||
memset(&m_InfoHeader, 0, sizeof(bitmapInfoHeaderExtended));
|
||||
m_FileHeader.bfType = 0x4D42;
|
||||
m_FileHeader.bfSize = sizeof(struct bitmapFileHeader);
|
||||
m_FileHeader.bfSize = sizeof(struct bitmapFileHeader) + sizeof(struct bitmapInfoHeaderExtended);
|
||||
m_FileHeader.bfReserved = 0;
|
||||
m_FileHeader.bfOffBits = sizeof(struct bitmapFileHeader) + sizeof(struct bitmapInfoHeader);
|
||||
m_FileHeader.bfOffBits = sizeof(struct bitmapFileHeader) + sizeof(struct bitmapInfoHeaderExtended);
|
||||
//EGAMI_ERROR("plopppppppppppppp " << m_FileHeader.bfOffBits);
|
||||
m_InfoHeader.biSize = sizeof(struct bitmapInfoHeader);
|
||||
m_InfoHeader.biSize = sizeof(struct bitmapInfoHeaderExtended);
|
||||
m_InfoHeader.biWidth = _inputImage.getSize().x();
|
||||
m_InfoHeader.biHeight = _inputImage.getSize().y();
|
||||
m_InfoHeader.biPlanes = 1;
|
||||
@ -298,12 +342,19 @@ bool egami::storeBMP(const std::string& _fileName, const egami::Image& _inputIma
|
||||
}
|
||||
m_InfoHeader.biSizeImage = (baseLine+offset)*_inputImage.getSize().y();
|
||||
}
|
||||
m_InfoHeader.biXPelsPerMeter = 75;
|
||||
m_InfoHeader.biYPelsPerMeter = 75;
|
||||
m_InfoHeader.biClrUsed = 0;
|
||||
m_InfoHeader.biClrImportant = 0;
|
||||
m_FileHeader.bfSize += m_InfoHeader.biSizeImage;
|
||||
m_InfoHeader.biXPelsPerMeter = 72*39.3701+1;
|
||||
m_InfoHeader.biYPelsPerMeter = 72*39.3701+1;
|
||||
//m_InfoHeader.biClrUsed = 0;
|
||||
//m_InfoHeader.biClrImportant = 0;
|
||||
|
||||
m_InfoHeader.biLCSColorSpace = 0x73524742; // "Win "
|
||||
|
||||
//display(m_FileHeader, m_InfoHeader);
|
||||
m_InfoHeader.biBitMaskRed = 0x0000FF00;
|
||||
m_InfoHeader.biBitMaskGreen = 0x00FF0000;
|
||||
m_InfoHeader.biBitMaskBlue = 0xFF000000;
|
||||
m_InfoHeader.biBitMaskAlpha = 0x000000FF;
|
||||
|
||||
etk::FSNode fileName(_fileName);
|
||||
if(false == fileName.fileOpenWrite() ) {
|
||||
@ -316,7 +367,7 @@ bool egami::storeBMP(const std::string& _fileName, const egami::Image& _inputIma
|
||||
fileName.fileClose();
|
||||
return false;
|
||||
}
|
||||
if (fileName.fileWrite(&m_InfoHeader,sizeof(struct bitmapInfoHeader),1) != 1) {
|
||||
if (fileName.fileWrite(&m_InfoHeader,sizeof(struct bitmapInfoHeaderExtended),1) != 1) {
|
||||
EGAMI_ERROR("error loading file header");
|
||||
fileName.fileClose();
|
||||
return false;
|
||||
@ -333,7 +384,7 @@ bool egami::storeBMP(const std::string& _fileName, const egami::Image& _inputIma
|
||||
uint8_t data[16];
|
||||
for(int32_t yyy=0; yyy<_inputImage.getSize().y(); ++yyy) {
|
||||
for(int32_t xxx=0; xxx<_inputImage.getSize().x(); ++xxx) {
|
||||
const etk::Color<>& tmpColor = _inputImage.get(ivec2(xxx,yyy));
|
||||
const etk::Color<>& tmpColor = _inputImage.get(ivec2(xxx,_inputImage.getSize().y()-yyy-1));
|
||||
uint8_t* pointer = data;
|
||||
*pointer++ = tmpColor.r();
|
||||
*pointer++ = tmpColor.g();
|
||||
@ -346,11 +397,11 @@ bool egami::storeBMP(const std::string& _fileName, const egami::Image& _inputIma
|
||||
uint8_t data[16];
|
||||
for(int32_t yyy=0; yyy<_inputImage.getSize().y(); ++yyy) {
|
||||
for(int32_t xxx=0; xxx<_inputImage.getSize().x(); ++xxx) {
|
||||
const etk::Color<>& tmpColor = _inputImage.get(ivec2(xxx,yyy));
|
||||
const etk::Color<>& tmpColor = _inputImage.get(ivec2(xxx,_inputImage.getSize().y()-yyy-1));
|
||||
uint8_t* pointer = data;
|
||||
*pointer++ = tmpColor.r();
|
||||
*pointer++ = tmpColor.g();
|
||||
*pointer++ = tmpColor.b();
|
||||
*pointer++ = tmpColor.g();
|
||||
*pointer++ = tmpColor.r();
|
||||
fileName.fileWrite(data,3,1);
|
||||
}
|
||||
if (offset != 0) {
|
||||
|
@ -107,12 +107,13 @@ egami::Image egami::loadJPG(const std::string& _inputFile) {
|
||||
|
||||
|
||||
// Here we use the library's state variable cinfo.output_scanline as the loop counter, so that we don't have to keep track ourselves.
|
||||
int32_t yyy = 1;
|
||||
int32_t yyy = 0;
|
||||
while (cinfo.output_scanline < cinfo.output_height) {
|
||||
// Get a simple line:
|
||||
(void) jpeg_read_scanlines(&cinfo, buffer, 1);
|
||||
// Direst push on the output (got output format RGB8)
|
||||
uint8_t* tmpp = dataOutPointer + (row_stride*(cinfo.output_height-yyy));
|
||||
//uint8_t* tmpp = dataOutPointer + (row_stride*(cinfo.output_height-yyy));
|
||||
uint8_t* tmpp = dataOutPointer + (row_stride*yyy);
|
||||
memcpy(tmpp, buffer[0], row_stride);
|
||||
yyy++;
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ egami::Image egami::loadPNG(const std::string& _inputFile) {
|
||||
for (png_uint_32 xxx = 0; xxx < width; ++xxx) {
|
||||
png_byte* ptr = &(row[xxx*4]);
|
||||
tmpColor.set(ptr[0], ptr[1], ptr[2], ptr[3]);
|
||||
out.set(ivec2(xxx,height-yyy-1), tmpColor);
|
||||
out.set(ivec2(xxx,yyy), tmpColor);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -223,7 +223,7 @@ egami::Image egami::loadPNG(const std::string& _inputFile) {
|
||||
for (png_uint_32 xxx = 0; xxx < width; ++xxx) {
|
||||
png_byte* ptr = &(row[xxx*3]);
|
||||
tmpColor.set(ptr[0], ptr[1], ptr[2]);
|
||||
out.set(ivec2(xxx,height-yyy-1), tmpColor);
|
||||
out.set(ivec2(xxx,yyy), tmpColor);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -235,7 +235,7 @@ egami::Image egami::loadPNG(const std::string& _inputFile) {
|
||||
for (png_uint_32 xxx = 0; xxx < width; ++xxx) {
|
||||
png_byte* ptr = &(row[xxx]);
|
||||
tmpColor.set(ptr[0], ptr[0], ptr[0]);
|
||||
out.set(ivec2(xxx,height-yyy-1), tmpColor);
|
||||
out.set(ivec2(xxx,yyy), tmpColor);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -247,7 +247,7 @@ egami::Image egami::loadPNG(const std::string& _inputFile) {
|
||||
for (png_uint_32 xxx = 0; xxx < width; ++xxx) {
|
||||
png_byte* ptr = &(row[xxx*2]);
|
||||
tmpColor.set(ptr[0], ptr[0], ptr[0], ptr[1]);
|
||||
out.set(ivec2(xxx,height-yyy-1), tmpColor);
|
||||
out.set(ivec2(xxx,yyy), tmpColor);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
1
lutinParseSubFolders.txt
Normal file
@ -0,0 +1 @@
|
||||
tools/viewer
|
@ -20,9 +20,9 @@ int main(int argc, const char *argv[]) {
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
TEST(TestBMP, read) {
|
||||
egami::Image image = egami::load("DATA:read.bmp");
|
||||
egami::store(image, "out/read.bmp.bmp");
|
||||
TEST(TestBMP, read_227x149) {
|
||||
egami::Image image = egami::load("DATA:read_227x149.bmp");
|
||||
egami::store(image, "out/read_227x149.bmp.bmp");
|
||||
// Check if image is loaded
|
||||
EXPECT_EQ(true, image.exist());
|
||||
// check image correct size
|
||||
@ -34,10 +34,38 @@ TEST(TestBMP, read) {
|
||||
EXPECT_EQ("3518a9693a349044d23c3a95262831144011086fdb339ef8532f9c6cebffe76b2c994b0a3e6d69addca15538a1cb559af3be445c5b622b5cf80c9291e7b8ca5b", sha512);
|
||||
}
|
||||
|
||||
TEST(TestBMP, read_128x128) {
|
||||
egami::Image image = egami::load("DATA:read_128x128.bmp");
|
||||
egami::store(image, "out/read_128x128.bmp.bmp");
|
||||
// Check if image is loaded
|
||||
EXPECT_EQ(true, image.exist());
|
||||
// check image correct size
|
||||
EXPECT_EQ(ivec2(128,128), image.getSize());
|
||||
// check image correct type
|
||||
EXPECT_EQ(egami::colorType::RGB8, image.getType());
|
||||
// check integrity
|
||||
std::string sha512 = algue::stringConvert(algue::sha512::encode((const uint8_t *)image.getTextureDataPointer(), egami::getFormatColorSize(image.getType()) * image.getSize().x() * image.getSize().y()));
|
||||
EXPECT_EQ("3518a9693a349044d23c3a95262831144011086fdb339ef8532f9c6cebffe76b2c994b0a3e6d69addca15538a1cb559af3be445c5b622b5cf80c9291e7b8ca5b", sha512);
|
||||
}
|
||||
|
||||
TEST(TestPNG, read) {
|
||||
egami::Image image = egami::load("DATA:read.png");
|
||||
egami::store(image, "out/read.png.bmp");
|
||||
|
||||
TEST(TestPNG, read_227x149) {
|
||||
egami::Image image = egami::load("DATA:read_227x149.png");
|
||||
egami::store(image, "out/read.png_227x149.bmp");
|
||||
// Check if image is loaded
|
||||
EXPECT_EQ(true, image.exist());
|
||||
// check image correct size
|
||||
EXPECT_EQ(ivec2(227,149), image.getSize());
|
||||
// check image correct type
|
||||
EXPECT_EQ(egami::colorType::RGB8, image.getType());
|
||||
// check integrity
|
||||
std::string sha512 = algue::stringConvert(algue::sha512::encode((const uint8_t *)image.getTextureDataPointer(), egami::getFormatColorSize(image.getType()) * image.getSize().x() * image.getSize().y()));
|
||||
EXPECT_EQ("42dbad7abf1e651da58c9df06521d63a878b5bd0db6e1cbe129db3c9782ce640a6709583ba9e6571d314f39b259321dcc392f98bf4412deb5ce8392566d2bc0f", sha512);
|
||||
}
|
||||
|
||||
TEST(TestPNG, read_128x128) {
|
||||
egami::Image image = egami::load("DATA:read_128x128.png");
|
||||
egami::store(image, "out/read_128x128.png.bmp");
|
||||
// Check if image is loaded
|
||||
EXPECT_EQ(true, image.exist());
|
||||
// check image correct size
|
||||
@ -64,9 +92,24 @@ TEST(TestSVG, read) {
|
||||
}
|
||||
|
||||
|
||||
TEST(TestJPG, read) {
|
||||
egami::Image image = egami::load("DATA:read.jpg");
|
||||
egami::store(image, "out/read.jpg.bmp");
|
||||
TEST(TestJPG, read_227x149) {
|
||||
egami::Image image = egami::load("DATA:read_227x149.jpg");
|
||||
egami::store(image, "out/read_227x149.jpg.bmp");
|
||||
// Check if image is loaded
|
||||
EXPECT_EQ(true, image.exist());
|
||||
// check image correct size
|
||||
EXPECT_EQ(ivec2(227,149), image.getSize());
|
||||
// check image correct type
|
||||
EXPECT_EQ(egami::colorType::RGB8, image.getType());
|
||||
// check integrity
|
||||
std::string sha512 = algue::stringConvert(algue::sha512::encode((const uint8_t *)image.getTextureDataPointer(), egami::getFormatColorSize(image.getType()) * image.getSize().x() * image.getSize().y()));
|
||||
EXPECT_EQ("42dbad7abf1e651da58c9df06521d63a878b5bd0db6e1cbe129db3c9782ce640a6709583ba9e6571d314f39b259321dcc392f98bf4412deb5ce8392566d2bc0f", sha512);
|
||||
}
|
||||
|
||||
|
||||
TEST(TestJPG, read_128x128) {
|
||||
egami::Image image = egami::load("DATA:read_128x128.jpg");
|
||||
egami::store(image, "out/read_128x128.jpg.bmp");
|
||||
// Check if image is loaded
|
||||
EXPECT_EQ(true, image.exist());
|
||||
// check image correct size
|
||||
|
123
tools/viewer/appl/MainWindows.cpp
Normal file
@ -0,0 +1,123 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/MainWindows.hpp>
|
||||
|
||||
#include <ewol/widget/Image.hpp>
|
||||
#include <ewol/context/Context.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <eproperty/Value.hpp>
|
||||
|
||||
appl::MainWindows::MainWindows() :
|
||||
m_idDisplayed(-1) {
|
||||
APPL_DEBUG("CREATE WINDOWS ... ");
|
||||
addObjectType("appl::MainWindows");
|
||||
}
|
||||
|
||||
void appl::MainWindows::init() {
|
||||
ewol::widget::Windows::init();
|
||||
m_image = ewol::widget::Image::create("src", std::string("DATA:icon.png"),
|
||||
"expand", bvec2(true,true),
|
||||
"fill", bvec2(true,true));
|
||||
propertyTitle.set("EVI");
|
||||
m_image->propertyExpand.set(bvec2(true,true));
|
||||
m_image->propertyFill.set(bvec2(true,true));
|
||||
setSubWidget(m_image);
|
||||
shortCutAdd("F12", "menu:reloade-shader");
|
||||
signalShortcut.connect(sharedFromThis(), &appl::MainWindows::onCallbackShortCut);
|
||||
}
|
||||
|
||||
void appl::MainWindows::onCallbackShortCut(const std::string& _value) {
|
||||
APPL_WARNING("Event from ShortCut : " << _value);
|
||||
if (_value == "menu:reloade-shader") {
|
||||
ewol::getContext().getResourcesManager().reLoadResources();
|
||||
ewol::getContext().forceRedrawAll();
|
||||
} else {
|
||||
APPL_ERROR("Event from Menu UNKNOW : '" << _value << "'");
|
||||
}
|
||||
}
|
||||
|
||||
void appl::MainWindows::setListOfFiles(std::vector<std::string> _listImages) {
|
||||
m_listImages = _listImages;
|
||||
if (m_listImages.size() == 0) {
|
||||
m_idDisplayed = -1;
|
||||
m_image->propertySource.set("DATA:icon.png");
|
||||
propertyTitle.set("EVI");
|
||||
} else {
|
||||
m_idDisplayed = 0;
|
||||
m_image->propertySource.set(m_listImages[0]);
|
||||
propertyTitle.set("EVI:" + m_listImages[0]);
|
||||
}
|
||||
}
|
||||
|
||||
bool appl::MainWindows::onEventInput(const ewol::event::Input& _event) {
|
||||
APPL_WARNING(" EVENT : " << _event);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool appl::MainWindows::onEventEntry(const ewol::event::Entry& _event) {
|
||||
if (m_idDisplayed == -1) {
|
||||
return false;
|
||||
}
|
||||
if (_event.getStatus() == gale::key::status::down) {
|
||||
if ( ( _event.getType() == gale::key::keyboard::character
|
||||
&& _event.getChar() == ' ')
|
||||
|| _event.getType() == gale::key::keyboard::right) {
|
||||
m_idDisplayed++;
|
||||
if (m_idDisplayed >= m_listImages.size()) {
|
||||
m_idDisplayed--;
|
||||
return true;
|
||||
}
|
||||
m_image->propertySource.set(m_listImages[m_idDisplayed]);
|
||||
propertyTitle.set("EVI:" + m_listImages[m_idDisplayed] + " " + etk::to_string(m_idDisplayed+1) + "/" + etk::to_string(m_listImages.size()));
|
||||
return true;
|
||||
}
|
||||
if (_event.getType() == gale::key::keyboard::left) {
|
||||
m_idDisplayed--;
|
||||
if (m_idDisplayed < 0) {
|
||||
m_idDisplayed++;
|
||||
return true;
|
||||
}
|
||||
m_image->propertySource.set(m_listImages[m_idDisplayed]);
|
||||
propertyTitle.set("EVI:" + m_listImages[m_idDisplayed] + " " + etk::to_string(m_idDisplayed+1) + "/" + etk::to_string(m_listImages.size()));
|
||||
return true;
|
||||
}
|
||||
if (_event.getType() == gale::key::keyboard::down) {
|
||||
m_idDisplayed += 10;
|
||||
if (m_idDisplayed >= m_listImages.size()) {
|
||||
m_idDisplayed = m_listImages.size()-1;
|
||||
}
|
||||
m_image->propertySource.set(m_listImages[m_idDisplayed]);
|
||||
propertyTitle.set("EVI:" + m_listImages[m_idDisplayed] + " " + etk::to_string(m_idDisplayed+1) + "/" + etk::to_string(m_listImages.size()));
|
||||
return true;
|
||||
}
|
||||
if (_event.getType() == gale::key::keyboard::up) {
|
||||
m_idDisplayed -= 10;
|
||||
if (m_idDisplayed < 0) {
|
||||
m_idDisplayed = 0;
|
||||
}
|
||||
m_image->propertySource.set(m_listImages[m_idDisplayed]);
|
||||
propertyTitle.set("EVI:" + m_listImages[m_idDisplayed] + " " + etk::to_string(m_idDisplayed+1) + "/" + etk::to_string(m_listImages.size()));
|
||||
return true;
|
||||
}
|
||||
if (_event.getType() == gale::key::keyboard::pageDown) {
|
||||
m_idDisplayed = m_listImages.size()-1;
|
||||
m_image->propertySource.set(m_listImages[m_idDisplayed]);
|
||||
propertyTitle.set("EVI:" + m_listImages[m_idDisplayed] + " " + etk::to_string(m_idDisplayed+1) + "/" + etk::to_string(m_listImages.size()));
|
||||
return true;
|
||||
}
|
||||
if (_event.getType() == gale::key::keyboard::pageUp) {
|
||||
m_idDisplayed = 0;
|
||||
m_image->propertySource.set(m_listImages[m_idDisplayed]);
|
||||
propertyTitle.set("EVI:" + m_listImages[m_idDisplayed] + " " + etk::to_string(m_idDisplayed+1) + "/" + etk::to_string(m_listImages.size()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
33
tools/viewer/appl/MainWindows.hpp
Normal file
@ -0,0 +1,33 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
#include <ewol/widget/Widget.hpp>
|
||||
#include <ewol/widget/Windows.hpp>
|
||||
#include <ewol/widget/Image.hpp>
|
||||
namespace appl {
|
||||
class MainWindows : public ewol::widget::Windows {
|
||||
private:
|
||||
ewol::widget::ImageShared m_image;
|
||||
std::vector<std::string> m_listImages;
|
||||
int64_t m_idDisplayed;
|
||||
public:
|
||||
// Constructeur
|
||||
MainWindows();
|
||||
void init() override;
|
||||
public:
|
||||
DECLARE_FACTORY(MainWindows);
|
||||
~MainWindows() {};
|
||||
void setListOfFiles(std::vector<std::string> _listImages);
|
||||
protected:
|
||||
void onCallbackShortCut(const std::string& _value);
|
||||
bool onEventInput(const ewol::event::Input& _event) override;
|
||||
bool onEventEntry(const ewol::event::Entry& _event) override;
|
||||
};
|
||||
};
|
||||
|
||||
|
13
tools/viewer/appl/debug.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
* @license GPL v3 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
|
||||
int32_t appl::getLogId() {
|
||||
static int32_t g_val = elog::registerInstance("egami-viewer");
|
||||
return g_val;
|
||||
}
|
45
tools/viewer/appl/debug.hpp
Normal file
@ -0,0 +1,45 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
* @license APACHE v2.0 (see license file)
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <elog/log.hpp>
|
||||
#include <cassert>
|
||||
|
||||
namespace appl {
|
||||
/**
|
||||
* @brief Get local id of the library
|
||||
* @return Unique ID of the library
|
||||
*/
|
||||
int32_t getLogId();
|
||||
};
|
||||
|
||||
#define APPL_BASIC(info,data) ELOG_BASE(appl::getLogId(),info,data)
|
||||
|
||||
#define APPL_PRINT(data) APPL_BASIC(-1, data)
|
||||
#define APPL_CRITICAL(data) APPL_BASIC(1, data)
|
||||
#define APPL_ERROR(data) APPL_BASIC(2, data)
|
||||
#define APPL_WARNING(data) APPL_BASIC(3, data)
|
||||
#ifdef DEBUG
|
||||
#define APPL_INFO(data) APPL_BASIC(4, data)
|
||||
#define APPL_DEBUG(data) APPL_BASIC(5, data)
|
||||
#define APPL_VERBOSE(data) APPL_BASIC(6, data)
|
||||
#define APPL_TODO(data) APPL_BASIC(4, "TODO : " << data)
|
||||
#else
|
||||
#define APPL_INFO(data) do { } while(false)
|
||||
#define APPL_DEBUG(data) do { } while(false)
|
||||
#define APPL_VERBOSE(data) do { } while(false)
|
||||
#define APPL_TODO(data) do { } while(false)
|
||||
#endif
|
||||
|
||||
#define APPL_HIDDEN(data) do { } while(false)
|
||||
|
||||
#define APPL_ASSERT(cond,data) \
|
||||
do { \
|
||||
if (!(cond)) { \
|
||||
APPL_CRITICAL(data); \
|
||||
assert(!#cond); \
|
||||
} \
|
||||
} while (0)
|
117
tools/viewer/appl/init.cpp
Normal file
@ -0,0 +1,117 @@
|
||||
/** @file
|
||||
* @author Edouard DUPIN
|
||||
* @copyright 2010, Edouard DUPIN, all right reserved
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <ewol/object/Object.hpp>
|
||||
#include <ewol/context/Context.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
|
||||
#include <appl/debug.hpp>
|
||||
#include <appl/MainWindows.hpp>
|
||||
|
||||
class MainApplication : public ewol::context::Application {
|
||||
private:
|
||||
std::vector<std::string> m_listFiles;
|
||||
public:
|
||||
virtual void onCreate(ewol::Context& _context) {
|
||||
APPL_INFO(" == > CREATE ... (START) [" << gale::getBoardType() << "] (" << gale::getCompilationMode() << ") (BEGIN)");
|
||||
for( int32_t iii=0 ; iii<_context.getCmd().size(); iii++) {
|
||||
std::string tmpppp = _context.getCmd().get(iii);
|
||||
if ( tmpppp == "-h"
|
||||
|| tmpppp == "--help") {
|
||||
APPL_INFO(" -t c-flags-file-name" );
|
||||
APPL_INFO(" -h/--help display this help" );
|
||||
exit(0);
|
||||
}
|
||||
if ( tmpppp.size()>=2
|
||||
&& tmpppp[0] == '-'
|
||||
&& tmpppp[1] == '-') {
|
||||
continue;
|
||||
}
|
||||
// TODO : Check if it is a path ...
|
||||
if (etk::FSNodeExist(tmpppp) == false) {
|
||||
APPL_ERROR("element does not exist: '" << tmpppp << "' ==> rejected");
|
||||
} else {
|
||||
etk::FSNode elem(tmpppp);
|
||||
if (elem.getNodeType() == etk::typeNode_folder) {
|
||||
std::vector<std::string> tmp = elem.folderGetSub(false, true, ".*");
|
||||
std::sort(tmp.begin(), tmp.end());
|
||||
for (auto &it : tmp) {
|
||||
m_listFiles.push_back(it);
|
||||
}
|
||||
} else {
|
||||
// simple file:
|
||||
m_listFiles.push_back(tmpppp);
|
||||
}
|
||||
}
|
||||
}
|
||||
//etk::theme::setName("COLOR", "color/black/");
|
||||
etk::theme::setName("COLOR", "color/white/");
|
||||
|
||||
_context.setSize(vec2(800, 600));
|
||||
|
||||
_context.setTitle("egami-viewer");
|
||||
|
||||
// select internal data for font ...
|
||||
_context.getFontDefault().setUseExternal(true);
|
||||
#ifdef __TARGET_OS__Android
|
||||
_context.getFontDefault().set("FreeSerif", 19);
|
||||
#else
|
||||
_context.getFontDefault().set("FreeSerif;DejaVuSansMono",14);
|
||||
#endif
|
||||
|
||||
// set the application icon ...
|
||||
_context.setIcon("DATA:icon.png");
|
||||
|
||||
APPL_INFO("==> CREATE ... (END)");
|
||||
}
|
||||
|
||||
void onStart(ewol::Context& _context) {
|
||||
APPL_INFO("==> START ... (BEGIN)");
|
||||
|
||||
ememory::SharedPtr<appl::MainWindows> basicWindows = appl::MainWindows::create();
|
||||
if (basicWindows == nullptr) {
|
||||
APPL_ERROR("Can not allocate the basic windows");
|
||||
return;
|
||||
}
|
||||
basicWindows->setListOfFiles(m_listFiles);
|
||||
// create the specific windows
|
||||
_context.setWindows(basicWindows);
|
||||
if (basicWindows == nullptr) {
|
||||
APPL_ERROR("Can not allocate the basic windows");
|
||||
_context.exit(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
// create the specific windows
|
||||
_context.setWindows(basicWindows);
|
||||
|
||||
APPL_INFO("==> START ... (END)");
|
||||
return;
|
||||
}
|
||||
|
||||
void onStop(ewol::Context& _context) {
|
||||
APPL_INFO("==> STOP ... (START)");
|
||||
APPL_INFO("==> STOP ... (END)");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Main of the program (This can be set in every case, but it is not used in Andoid...).
|
||||
* @param std IO
|
||||
* @return std IO
|
||||
*/
|
||||
int main(int _argc, const char *_argv[]) {
|
||||
// second possibility
|
||||
return ewol::run(new MainApplication(), _argc, _argv);
|
||||
}
|
||||
|
||||
|
BIN
tools/viewer/data/icon.png
Normal file
After Width: | Height: | Size: 13 KiB |
61
tools/viewer/lutin_egami-viewer.py
Executable file
@ -0,0 +1,61 @@
|
||||
#!/usr/bin/python
|
||||
import lutin.debug as debug
|
||||
import lutin.tools as tools
|
||||
import os
|
||||
|
||||
def get_type():
|
||||
return "BINARY"
|
||||
|
||||
def get_sub_type():
|
||||
return "TOOL"
|
||||
|
||||
def get_desc():
|
||||
return "egami simple image viewer (visual)"
|
||||
|
||||
def get_licence():
|
||||
return "APACHE-2"
|
||||
|
||||
def get_compagny_type():
|
||||
return "com"
|
||||
|
||||
def get_compagny_name():
|
||||
return "atria-soft"
|
||||
|
||||
def get_maintainer():
|
||||
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||
|
||||
def configure(target, my_module):
|
||||
# add the file to compile:
|
||||
my_module.add_src_file([
|
||||
'appl/debug.cpp',
|
||||
'appl/init.cpp',
|
||||
'appl/MainWindows.cpp',
|
||||
])
|
||||
|
||||
my_module.add_depend(['ewol'])
|
||||
|
||||
my_module.copy_file('data/icon.png','icon.png')
|
||||
|
||||
my_module.add_path(".")
|
||||
|
||||
"""
|
||||
# set the package properties :
|
||||
my_module.pkg_set("VERSION", versionID)
|
||||
my_module.pkg_set("COMPAGNY_TYPE", "org")
|
||||
my_module.pkg_set("COMPAGNY_NAME", "Edouard DUPIN")
|
||||
my_module.pkg_set("MAINTAINER", ["Mr DUPIN Edouard <yui.heero@gmail.com>"])
|
||||
my_module.pkg_set("ICON", tools.get_current_path(__file__) + "/../data/icon.png")
|
||||
my_module.pkg_set("SECTION", ["Development"])
|
||||
my_module.pkg_set("PRIORITY", "optional")
|
||||
my_module.pkg_set("DESCRIPTION", "ewol test software")
|
||||
my_module.pkg_set("NAME", "test software")
|
||||
|
||||
my_module.pkg_add("RIGHT", "SET_ORIENTATION")
|
||||
my_module.pkg_add("RIGHT", "VIBRATE")
|
||||
"""
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
|