| 173 | } |
| 174 | |
| 175 | bool Bitmap::WritePNG(std::ostream& os) const { |
| 176 | size_t const width = GetWidth(), height = GetHeight(); |
| 177 | size_t const stride = width * 4; |
| 178 | |
| 179 | std::vector<uint32_t> data(width * height); |
| 180 | |
| 181 | #ifdef WORDS_BIGENDIAN |
| 182 | auto format = PIXMAN_r8g8b8; |
| 183 | #else |
| 184 | auto format = PIXMAN_b8g8r8; |
| 185 | #endif |
| 186 | |
| 187 | auto dst = PixmanImagePtr{pixman_image_create_bits(format, width, height, &data.front(), stride)}; |
| 188 | pixman_image_composite32(PIXMAN_OP_SRC, bitmap.get(), NULL, dst.get(), |
| 189 | 0, 0, 0, 0, 0, 0, width, height); |
| 190 | |
| 191 | return ImagePNG::Write(os, width, height, &data.front()); |
| 192 | } |
| 193 | |
| 194 | size_t Bitmap::GetSize() const { |
| 195 | if (!bitmap) { |