[DEV] update to esvg 0.6-dev and create basic dev version
This commit is contained in:
parent
324a951c3c
commit
bccb11804d
@ -256,4 +256,11 @@ void egami::Image::set(const ivec2& _pos, const etk::Color<double, 1>& _newColor
|
||||
m_data->set(_pos, _newColor);
|
||||
}
|
||||
|
||||
void egami::Image::set(const std::vector<etk::Color<float,4>>& _data, const ivec2& _size) {
|
||||
if (m_data == nullptr) {
|
||||
EGAMI_WARNING("No internal data for image : Can not set color");
|
||||
return;
|
||||
}
|
||||
m_data->set(_data, _size);
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,8 @@ namespace egami {
|
||||
* @TODO Set this function more capacity like not a multiple ratio...
|
||||
*/
|
||||
void scale(const ivec2& _size);
|
||||
|
||||
void set(const std::vector<etk::Color<float,4>>& _data, const ivec2& _size);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -39,6 +39,7 @@ namespace egami {
|
||||
virtual void set(const ivec2& _pos, const etk::Color<float, 1>& _newColor) = 0;
|
||||
virtual void set(const ivec2& _pos, const etk::Color<double, 1>& _newColor) = 0;
|
||||
virtual etk::Color<> get(const ivec2& _pos) const = 0;
|
||||
virtual void set(const std::vector<etk::Color<float,4>>& _data, const ivec2& _size) = 0;
|
||||
};
|
||||
|
||||
template<typename T = etk::Color<>>
|
||||
@ -234,6 +235,14 @@ namespace egami {
|
||||
}
|
||||
resize(_size);
|
||||
}
|
||||
void set(const std::vector<etk::Color<float,4>>& _data, const ivec2& _size) {
|
||||
m_data.clear();
|
||||
m_size = _size;
|
||||
m_data.resize(_data.size());
|
||||
for (size_t iii=0; iii<m_data.size(); ++iii) {
|
||||
m_data[iii] = _data[iii];
|
||||
}
|
||||
}
|
||||
};
|
||||
template <> enum colorType ImageTemplate<etk::Color<uint8_t>>::getType() {
|
||||
return colorRGBA8;
|
||||
|
@ -58,11 +58,11 @@ bool egami::loadBMP(const std::string& _inputFile, egami::Image& _ouputImage) {
|
||||
EWOL_ERROR("not enought data in the file named=\"" << fileName << "\"");
|
||||
return;
|
||||
}*/
|
||||
if (false == fileName.exist()) {
|
||||
if (fileName.exist() == false) {
|
||||
EGAMI_ERROR("File does not existed=\"" << fileName << "\"");
|
||||
return false;
|
||||
}
|
||||
if(false == fileName.fileOpenRead() ) {
|
||||
if(fileName.fileOpenRead() ==false) {
|
||||
EGAMI_ERROR("Can not find the file name=\"" << fileName << "\"");
|
||||
return false;
|
||||
}
|
||||
@ -77,7 +77,7 @@ bool egami::loadBMP(const std::string& _inputFile, egami::Image& _ouputImage) {
|
||||
fileName.fileClose();
|
||||
return false;
|
||||
}
|
||||
if(false == fileName.fileSeek(m_FileHeader.bfOffBits, etk::FSN_SEEK_START)) {
|
||||
if(fileName.fileSeek(m_FileHeader.bfOffBits, etk::FSN_SEEK_START) == false) {
|
||||
EGAMI_ERROR("error with the 'bfOffBits' in the file named=\"" << fileName << "\"");
|
||||
fileName.fileClose();
|
||||
return false;
|
||||
@ -123,10 +123,10 @@ bool egami::loadBMP(const std::string& _inputFile, egami::Image& _ouputImage) {
|
||||
// reallocate the image
|
||||
_ouputImage.resize(ivec2(m_width,m_height));
|
||||
|
||||
uint8_t* m_data = NULL;
|
||||
std::vector<uint8_t> m_data;
|
||||
if(0 != m_InfoHeader.biSizeImage) {
|
||||
m_data=new uint8_t[m_InfoHeader.biSizeImage];
|
||||
if (fileName.fileRead(m_data,m_InfoHeader.biSizeImage,1) != 1){
|
||||
m_data.resize(m_InfoHeader.biSizeImage, 0);
|
||||
if (fileName.fileRead(&m_data[0],m_InfoHeader.biSizeImage,1) != 1){
|
||||
EGAMI_CRITICAL("Can not read the file with the good size...");
|
||||
}
|
||||
}
|
||||
@ -137,7 +137,7 @@ bool egami::loadBMP(const std::string& _inputFile, egami::Image& _ouputImage) {
|
||||
// need now to generate RGBA data ...
|
||||
switch(m_dataMode) {
|
||||
case BITS_16_R5G6B5: {
|
||||
uint16_t * pointer = (uint16_t*)m_data;
|
||||
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));
|
||||
@ -151,7 +151,7 @@ bool egami::loadBMP(const std::string& _inputFile, egami::Image& _ouputImage) {
|
||||
}
|
||||
break;
|
||||
case BITS_16_X1R5G5B5: {
|
||||
uint16_t * pointer = (uint16_t*)m_data;
|
||||
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));
|
||||
@ -165,7 +165,7 @@ bool egami::loadBMP(const std::string& _inputFile, egami::Image& _ouputImage) {
|
||||
}
|
||||
break;
|
||||
case BITS_24_R8G8B8: {
|
||||
uint8_t * pointer = m_data;
|
||||
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++);
|
||||
@ -178,7 +178,7 @@ bool egami::loadBMP(const std::string& _inputFile, egami::Image& _ouputImage) {
|
||||
}
|
||||
break;
|
||||
case BITS_32_X8R8G8B8: {
|
||||
uint8_t * pointer = m_data;
|
||||
uint8_t * pointer = (&m_data[0]);
|
||||
for(int32_t yyy=0; yyy<m_height; yyy++) {
|
||||
for(int32_t xxx=0; xxx<m_width; xxx++) {
|
||||
pointer++;
|
||||
@ -192,7 +192,7 @@ bool egami::loadBMP(const std::string& _inputFile, egami::Image& _ouputImage) {
|
||||
}
|
||||
break;
|
||||
case BITS_32_A8R8G8B8: {
|
||||
uint8_t * pointer = m_data;
|
||||
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++);
|
||||
@ -208,10 +208,6 @@ bool egami::loadBMP(const std::string& _inputFile, egami::Image& _ouputImage) {
|
||||
EGAMI_ERROR(" mode = ERROR");
|
||||
break;
|
||||
}
|
||||
if (NULL != m_data) {
|
||||
delete(m_data);
|
||||
m_data=NULL;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -260,8 +256,8 @@ 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++) {
|
||||
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));
|
||||
uint8_t* pointer = data;
|
||||
*pointer++ = tmpColor.r();
|
||||
|
@ -19,26 +19,13 @@
|
||||
|
||||
|
||||
bool egami::loadSVG(const std::string& _fileName, egami::Image& _ouputImage, const ivec2& _size) {
|
||||
esvg::Document m_element(_fileName);
|
||||
if (false == m_element.isLoadOk()) {
|
||||
esvg::Document svgDocument;
|
||||
if (svgDocument.load(_fileName) == false) {
|
||||
EGAMI_ERROR("Error to load SVG file " << _fileName );
|
||||
return false;
|
||||
}
|
||||
draw::Image tmpImage;
|
||||
if( _size.x()>0
|
||||
&& _size.y()>0 ) {
|
||||
m_element.generateAnImage(_size, tmpImage);
|
||||
} else {
|
||||
m_element.generateAnImage(tmpImage);
|
||||
}
|
||||
// generate the output image in the corect format:
|
||||
_ouputImage.resize(tmpImage.getSize(), etk::color::white);
|
||||
for (int32_t jjj=0; jjj<tmpImage.getSize().y(); jjj++) {
|
||||
for (int32_t iii=0; iii<tmpImage.getSize().x(); iii++) {
|
||||
ivec2 tmppos(iii,jjj);
|
||||
draw::Color tmpColor = tmpImage.get(tmppos);
|
||||
_ouputImage.set(tmppos, etk::Color<>(tmpColor.r, tmpColor.g, tmpColor.b, tmpColor.a) );
|
||||
}
|
||||
}
|
||||
ivec2 imageSize = _size;
|
||||
std::vector<etk::Color<float,4>> svgImage = svgDocument.renderImageFloatRGBA(imageSize);
|
||||
_ouputImage.set(svgImage, imageSize);
|
||||
return true;
|
||||
}
|
@ -22,7 +22,7 @@ def get_maintainer():
|
||||
return ["Mr DUPIN Edouard <yui.heero@gmail.com>"]
|
||||
|
||||
def get_version():
|
||||
return [0,0,0]
|
||||
return [0,1,"dev"]
|
||||
|
||||
def create(target, module_name):
|
||||
my_module = module.Module(__file__, module_name, get_type())
|
||||
|
Loading…
x
Reference in New Issue
Block a user