35 m_pixels.resize(size.
area() * bpp, 0);
37 memcpy(&m_pixels[0], pixels, m_pixels.size());
57 std::stringstream fin;
75 std::stringstream data;
77 fin->
write(data.str().c_str(), data.str().length());
87 uint8& r = m_pixels[p * 4 + 0];
88 uint8& g = m_pixels[p * 4 + 1];
89 uint8& b = m_pixels[p * 4 + 2];
90 uint8& a = m_pixels[p * 4 + 3];
92 Color pixelColor(r, g, b, a);
93 Color writeColor = (pixelColor == maskedColor) ? insideColor : outsideColor;
109 int coloredPixelSize = 0;
111 uint8* otherPixels = other->getPixelData();
112 for (
int p = 0; p < other->getPixelCount(); ++p) {
113 int x = p % other->getWidth();
114 int y = p / other->getWidth();
115 int pos = ((dest.
y + y) * m_size.
width() + (dest.
x + x)) * 4;
117 if (otherPixels[p * 4 + 3] != 0) {
118 m_pixels[pos + 0] = otherPixels[p * 4 + 0];
119 m_pixels[pos + 1] = otherPixels[p * 4 + 1];
120 m_pixels[pos + 2] = otherPixels[p * 4 + 2];
121 m_pixels[pos + 3] = otherPixels[p * 4 + 3];
134 uint8* otherPixels = other->getPixelData();
135 for (
int p = 0; p < other->getPixelCount(); ++p) {
136 int x = p % other->getWidth();
137 int y = p / other->getWidth();
138 int pos = (y * m_size.
width() + x) * 4;
140 m_pixels[pos + 0] = otherPixels[p * 4 + 0];
141 m_pixels[pos + 1] = otherPixels[p * 4 + 1];
142 m_pixels[pos + 2] = otherPixels[p * 4 + 2];
143 m_pixels[pos + 3] = otherPixels[p * 4 + 3];
152 int iw = m_size.
width();
154 if (iw == 1 && ih == 1)
157 int ow = iw > 1 ? iw / 2 : 1;
158 int oh = ih > 1 ? ih / 2 : 1;
160 std::vector<uint8> pixels(ow * oh * 4, 0xFF);
163 if (iw != 1 && ih != 1) {
164 for (
int x = 0; x < ow; ++x) {
165 for (
int y = 0; y < oh; ++y) {
167 inPixel[0] = &m_pixels[((y * 2) * iw + (x * 2)) * 4];
168 inPixel[1] = &m_pixels[((y * 2) * iw + (x * 2) + 1) * 4];
169 inPixel[2] = &m_pixels[((y * 2 + 1) * iw + (x * 2)) * 4];
170 inPixel[3] = &m_pixels[((y * 2 + 1) * iw + (x * 2) + 1) * 4];
171 uint8* outPixel = &pixels[(y * ow + x) * 4];
174 for (
int i = 0; i < 4; ++i)
178 for (
int j = 0; j < 4; ++j) {
180 if (inPixel[j][3] < 16)
183 for (
int i = 0; i < 4; ++i)
184 pixelsSum[i] += inPixel[j][i];
190 for (
int i = 0; i < 4; ++i) {
192 outPixel[i] = pixelsSum[i] / usedPixels;
196 outPixel[3] = pixelsSum[3] / 4;
202 m_size =
Size(ow, oh);