[DEV] better integration of lib esvg
This commit is contained in:
parent
ec9d67e1bb
commit
0c23fe23a3
@ -264,3 +264,11 @@ void egami::Image::set(const std::vector<etk::Color<float,4>>& _data, const ivec
|
|||||||
m_data->set(_data, _size);
|
m_data->set(_data, _size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void egami::Image::set(const std::vector<etk::Color<uint8_t,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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ namespace egami {
|
|||||||
void scale(const ivec2& _size);
|
void scale(const ivec2& _size);
|
||||||
|
|
||||||
void set(const std::vector<etk::Color<float,4>>& _data, const ivec2& _size);
|
void set(const std::vector<etk::Color<float,4>>& _data, const ivec2& _size);
|
||||||
|
void set(const std::vector<etk::Color<uint8_t,4>>& _data, const ivec2& _size);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ namespace egami {
|
|||||||
virtual void set(const ivec2& _pos, const etk::Color<double, 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 etk::Color<> get(const ivec2& _pos) const = 0;
|
||||||
virtual void set(const std::vector<etk::Color<float,4>>& _data, const ivec2& _size) = 0;
|
virtual void set(const std::vector<etk::Color<float,4>>& _data, const ivec2& _size) = 0;
|
||||||
|
virtual void set(const std::vector<etk::Color<uint8_t,4>>& _data, const ivec2& _size) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T = etk::Color<>>
|
template<typename T = etk::Color<>>
|
||||||
@ -243,6 +244,14 @@ namespace egami {
|
|||||||
m_data[iii] = _data[iii];
|
m_data[iii] = _data[iii];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void set(const std::vector<etk::Color<uint8_t,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() {
|
template <> enum colorType ImageTemplate<etk::Color<uint8_t>>::getType() {
|
||||||
return colorRGBA8;
|
return colorRGBA8;
|
||||||
|
@ -25,24 +25,25 @@ bool egami::scalable(const std::string& _fileName) {
|
|||||||
bool egami::load(egami::Image& _output, const std::string& _fileName, const ivec2& _size) {
|
bool egami::load(egami::Image& _output, const std::string& _fileName, const ivec2& _size) {
|
||||||
std::string tmpName = etk::tolower(_fileName);
|
std::string tmpName = etk::tolower(_fileName);
|
||||||
// select the corect Loader :
|
// select the corect Loader :
|
||||||
if (true == etk::end_with(tmpName, ".edf") ) { // internal format for ewol distance field ==> simple sistance field image
|
if (etk::end_with(tmpName, ".edf") == true) {
|
||||||
if (false == egami::loadEDF(_fileName, _output)) {
|
// internal format for ewol distance field ==> simple sistance field image
|
||||||
|
if (egami::loadEDF(_fileName, _output) == false) {
|
||||||
EGAMI_ERROR("Error to load EDF file '" << _fileName << "'");
|
EGAMI_ERROR("Error to load EDF file '" << _fileName << "'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (true == etk::end_with(tmpName, ".bmp") ) {
|
} else if (etk::end_with(tmpName, ".bmp") == true) {
|
||||||
if (false == egami::loadBMP(_fileName, _output)) {
|
if (egami::loadBMP(_fileName, _output) == false) {
|
||||||
EGAMI_ERROR("Error to load BMP file '" << _fileName << "'");
|
EGAMI_ERROR("Error to load BMP file '" << _fileName << "'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (true == etk::end_with(tmpName, ".svg") ) {
|
} else if (etk::end_with(tmpName, ".svg") == true) {
|
||||||
if (false == egami::loadSVG(_fileName, _output, _size)) {
|
if (egami::loadSVG(_fileName, _output, _size) == false) {
|
||||||
EGAMI_ERROR("Error to load SVG file '" << _fileName << "'");
|
EGAMI_ERROR("Error to load SVG file '" << _fileName << "'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//egami::storeEDF(_fileName + ".edf", _output);
|
//egami::storeEDF(_fileName + ".edf", _output);
|
||||||
} else if (true == etk::end_with(tmpName, ".png") ) {
|
} else if (etk::end_with(tmpName, ".png") == true) {
|
||||||
if (false == egami::loadPNG(_fileName, _output)) {
|
if (egami::loadPNG(_fileName, _output) == false) {
|
||||||
EGAMI_ERROR("Error to load PNG file '" << _fileName << "'");
|
EGAMI_ERROR("Error to load PNG file '" << _fileName << "'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -57,20 +58,20 @@ bool egami::store(const egami::Image& _input, const std::string& _fileName) {
|
|||||||
std::string tmpName = etk::tolower(_fileName);
|
std::string tmpName = etk::tolower(_fileName);
|
||||||
EGAMI_DEBUG("Store file : " << _fileName);
|
EGAMI_DEBUG("Store file : " << _fileName);
|
||||||
// select the corect Loader :
|
// select the corect Loader :
|
||||||
if (true == etk::end_with(tmpName, ".edf") ) {
|
if (etk::end_with(tmpName, ".edf") == true) {
|
||||||
if (false == egami::storeEDF(_fileName, _input)) {
|
if (egami::storeEDF(_fileName, _input) == false) {
|
||||||
EGAMI_ERROR("Error to load EDF file '" << _fileName << "'");
|
EGAMI_ERROR("Error to load EDF file '" << _fileName << "'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (true == etk::end_with(tmpName, ".bmp") ) {
|
} else if (etk::end_with(tmpName, ".bmp") == true) {
|
||||||
if (false == egami::storeBMP(_fileName, _input)) {
|
if (egami::storeBMP(_fileName, _input) == false) {
|
||||||
EGAMI_ERROR("Error to load BMP file '" << _fileName << "'");
|
EGAMI_ERROR("Error to load BMP file '" << _fileName << "'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (true == etk::end_with(tmpName, ".svg") ) {
|
} else if (etk::end_with(tmpName, ".svg") == true) {
|
||||||
EGAMI_ERROR("Can not store in SVG file '" << _fileName << "'");
|
EGAMI_ERROR("Can not store in SVG file '" << _fileName << "'");
|
||||||
return false;
|
return false;
|
||||||
} else if (true == etk::end_with(tmpName, ".png") ) {
|
} else if (etk::end_with(tmpName, ".png") == true) {
|
||||||
EGAMI_ERROR("Can not store in PNG file '" << _fileName << "'");
|
EGAMI_ERROR("Can not store in PNG file '" << _fileName << "'");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -25,7 +25,12 @@ bool egami::loadSVG(const std::string& _fileName, egami::Image& _ouputImage, con
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ivec2 imageSize = _size;
|
ivec2 imageSize = _size;
|
||||||
std::vector<etk::Color<float,4>> svgImage = svgDocument.renderImageFloatRGBA(imageSize);
|
#if 0
|
||||||
_ouputImage.set(svgImage, imageSize);
|
std::vector<etk::Color<float,4>> svgImage = svgDocument.renderImageFloatRGBA(imageSize);
|
||||||
|
_ouputImage.set(svgImage, imageSize);
|
||||||
|
#else
|
||||||
|
std::vector<etk::Color<uint8_t,4>> svgImage = svgDocument.renderImageU8RGBA(imageSize);
|
||||||
|
_ouputImage.set(svgImage, imageSize);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user