[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);
|
||||
}
|
||||
|
||||
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 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 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<uint8_t,4>>& _data, const ivec2& _size) = 0;
|
||||
};
|
||||
|
||||
template<typename T = etk::Color<>>
|
||||
@ -243,6 +244,14 @@ namespace egami {
|
||||
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() {
|
||||
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) {
|
||||
std::string tmpName = etk::tolower(_fileName);
|
||||
// select the corect Loader :
|
||||
if (true == etk::end_with(tmpName, ".edf") ) { // internal format for ewol distance field ==> simple sistance field image
|
||||
if (false == egami::loadEDF(_fileName, _output)) {
|
||||
if (etk::end_with(tmpName, ".edf") == true) {
|
||||
// internal format for ewol distance field ==> simple sistance field image
|
||||
if (egami::loadEDF(_fileName, _output) == false) {
|
||||
EGAMI_ERROR("Error to load EDF file '" << _fileName << "'");
|
||||
return false;
|
||||
}
|
||||
} else if (true == etk::end_with(tmpName, ".bmp") ) {
|
||||
if (false == egami::loadBMP(_fileName, _output)) {
|
||||
} else if (etk::end_with(tmpName, ".bmp") == true) {
|
||||
if (egami::loadBMP(_fileName, _output) == false) {
|
||||
EGAMI_ERROR("Error to load BMP file '" << _fileName << "'");
|
||||
return false;
|
||||
}
|
||||
} else if (true == etk::end_with(tmpName, ".svg") ) {
|
||||
if (false == egami::loadSVG(_fileName, _output, _size)) {
|
||||
} else if (etk::end_with(tmpName, ".svg") == true) {
|
||||
if (egami::loadSVG(_fileName, _output, _size) == false) {
|
||||
EGAMI_ERROR("Error to load SVG file '" << _fileName << "'");
|
||||
return false;
|
||||
}
|
||||
//egami::storeEDF(_fileName + ".edf", _output);
|
||||
} else if (true == etk::end_with(tmpName, ".png") ) {
|
||||
if (false == egami::loadPNG(_fileName, _output)) {
|
||||
} else if (etk::end_with(tmpName, ".png") == true) {
|
||||
if (egami::loadPNG(_fileName, _output) == false) {
|
||||
EGAMI_ERROR("Error to load PNG file '" << _fileName << "'");
|
||||
return false;
|
||||
}
|
||||
@ -57,20 +58,20 @@ bool egami::store(const egami::Image& _input, const std::string& _fileName) {
|
||||
std::string tmpName = etk::tolower(_fileName);
|
||||
EGAMI_DEBUG("Store file : " << _fileName);
|
||||
// select the corect Loader :
|
||||
if (true == etk::end_with(tmpName, ".edf") ) {
|
||||
if (false == egami::storeEDF(_fileName, _input)) {
|
||||
if (etk::end_with(tmpName, ".edf") == true) {
|
||||
if (egami::storeEDF(_fileName, _input) == false) {
|
||||
EGAMI_ERROR("Error to load EDF file '" << _fileName << "'");
|
||||
return false;
|
||||
}
|
||||
} else if (true == etk::end_with(tmpName, ".bmp") ) {
|
||||
if (false == egami::storeBMP(_fileName, _input)) {
|
||||
} else if (etk::end_with(tmpName, ".bmp") == true) {
|
||||
if (egami::storeBMP(_fileName, _input) == false) {
|
||||
EGAMI_ERROR("Error to load BMP file '" << _fileName << "'");
|
||||
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 << "'");
|
||||
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 << "'");
|
||||
return false;
|
||||
} else {
|
||||
|
@ -25,7 +25,12 @@ bool egami::loadSVG(const std::string& _fileName, egami::Image& _ouputImage, con
|
||||
return false;
|
||||
}
|
||||
ivec2 imageSize = _size;
|
||||
std::vector<etk::Color<float,4>> svgImage = svgDocument.renderImageFloatRGBA(imageSize);
|
||||
_ouputImage.set(svgImage, imageSize);
|
||||
#if 0
|
||||
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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user