17 template<
typename T = etk::Color<>>
21 std::vector<T> m_data;
29 m_data.resize(m_size.
x()*m_size.
y(), tmpBg);
30 if ((uint32_t)m_size.
x()*m_size.
y() > m_data.size()) {
40 void* getTextureDataPointer() {
43 enum colorType getType()
const;
44 const ivec2& getSize() {
52 if (_size == m_size) {
56 if ((
size_t)(_size.
x()*_size.
y()) > m_data.size()) {
57 m_data.resize(_size.
x()*_size.
y());
60 if (_size.
x() == m_size.
x()) {
61 if (_size.
y() < m_size.
y()) {
66 }
else if (_size.
x() < m_size.
x()) {
67 if (_size.
y() <= m_size.
y()) {
68 for (int32_t yyy=0; yyy<_size.
y(); ++yyy) {
69 for (int32_t xxx=0; xxx<_size.
x(); ++xxx) {
70 m_data[yyy*_size.
x()+xxx] = m_data[yyy*m_size.
x()+xxx];
74 for (int32_t yyy=m_size.
y()-1; yyy>=0; --yyy) {
75 for (int32_t xxx=0; xxx<_size.
x(); ++xxx) {
76 m_data[yyy*_size.
x()+xxx] = m_data[yyy*m_size.
x()+xxx];
82 if (_size.
y() <= m_size.
y()) {
83 for (int32_t yyy=0; yyy<_size.
y(); ++yyy) {
84 for (int32_t xxx=0; xxx<m_size.
x(); ++xxx) {
85 m_data[yyy*_size.
x()+xxx] = m_data[yyy*m_size.
x()+xxx];
89 for (int32_t yyy=m_size.
y()-1; yyy>=0; --yyy) {
90 for (int32_t xxx=0; xxx<m_size.
x(); ++xxx) {
91 m_data[yyy*_size.
x()+xxx] = m_data[yyy*m_size.
x()+xxx];
96 if ((
size_t)(_size.
x()*_size.
y()) < m_data.size()) {
97 m_data.resize(_size.
x()*_size.
y());
101 void resize__(
const ivec2& _size,
const T& _color) {
103 m_data.resize(m_size.
x()*m_size.
y(), _color);
107 resize__(_size, _color);
110 resize__(_size, _color);
113 resize__(_size, _color);
116 resize__(_size, _color);
119 resize__(_size, _color);
122 resize__(_size, _color);
125 void resize(
const ivec2& _size,
const ivec2& _startPos) {
128 template<
typename TYPE_2>
void resize(
const ivec2& _size,
const TYPE_2& _color) {
130 resize__(_size, tmp);
133 set__(_pos, _newColor);
136 set__(_pos, _newColor);
139 set__(_pos, _newColor);
142 set__(_pos, _newColor);
145 set__(_pos, _newColor);
148 set__(_pos, _newColor);
151 const ivec2& getSize()
const {
154 int32_t getWidth()
const {
157 int32_t getHeight()
const {
160 void clearColor(
const T& _fill) {
161 for (int32_t iii=0; iii<m_size.
x()*m_size.
y(); iii++) {
166 clearColor(T::emptyColor);
172 const T& get__(
const ivec2& _pos)
const {
173 static const T errorColor(0x00000000);
174 if( _pos.
x()>0 && _pos.
x()<m_size.
x()
175 && _pos.
y()>0 && _pos.
y()<m_size.
y()) {
176 return m_data[_pos.
x()+_pos.
y()*m_size.
x()];
180 void set__(
const ivec2& _pos,
const T& _newColor) {
181 if( _pos.
x()>=0 && _pos.
x()<m_size.
x()
182 && _pos.
y()>=0 && _pos.
y()<m_size.
y()) {
183 m_data[_pos.
x()+_pos.
y()*m_size.
x()] = _newColor;
187 for(int32_t yyy = 0; yyy < _input.getSize().
y() && _pos.
y() + yyy < m_size.
y(); ++yyy) {
188 for(int32_t xxx = 0; xxx < _input.getSize().
x() && _pos.
x() + xxx < m_size.
x(); ++xxx) {
189 set(
ivec2(_pos.
x()+xxx, _pos.
y()+yyy), _input.get(
ivec2(xxx, yyy)) );
200 int32_t stepX = m_size.
x() / _size.
x();
201 int32_t stepY = m_size.
y() / _size.
y();
202 stepX = std::max(1, stepX);
203 stepY = std::max(1, stepY);
204 EGAMI_VERBOSE(
"move : " << stepX <<
" , " << stepY <<
" from : " << m_size <<
" ==> " << _size);
205 for (int32_t yyy = 0; yyy < _size.
y(); ++yyy) {
206 for (int32_t xxx = 0; xxx < _size.
x(); ++xxx) {
207 set(
ivec2(xxx, yyy),
get(
ivec2(xxx*stepX, yyy*stepY)));
212 void set(
const std::vector<etk::Color<float,4>>& _data,
const ivec2& _size) {
215 m_data.resize(_data.size());
216 for (
size_t iii=0; iii<m_data.size(); ++iii) {
217 m_data[iii] = _data[iii];
220 void set(
const std::vector<etk::Color<uint8_t,4>>& _data,
const ivec2& _size) {
223 m_data.resize(_data.size());
224 for (
size_t iii=0; iii<m_data.size(); ++iii) {
225 m_data[iii] = _data[iii];
230 return egami::colorType::RGBA8;
233 return egami::colorType::RGB8;
236 return egami::colorType::RGBAf;
239 return egami::colorType::RGBf;
242 return egami::colorType::unsignedInt16;
245 return egami::colorType::unsignedInt32;
248 return egami::colorType::float32;
251 return egami::colorType::float64;
Definition: ImagePrivate.hpp:18
void scale(const ivec2 &_size)
Scale an image in an other dimention.
Definition: ImagePrivate.hpp:198