| 82 | } |
| 83 | |
| 84 | std::string getPNGData() { |
| 85 | auto w = img()->width(); |
| 86 | auto h = img()->height(); |
| 87 | std::shared_ptr<she::Surface> surface{ |
| 88 | she::instance()->createRgbaSurface(w, h), |
| 89 | [](auto s) {s->dispose();} |
| 90 | }; |
| 91 | if (!surface) |
| 92 | return ""; |
| 93 | |
| 94 | for (auto y = 0; y < h; ++y) { |
| 95 | for (auto x = 0; x < w; ++x) { |
| 96 | surface->putPixel(img()->getPixel(x, y), x, y); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | std::string encoded; |
| 101 | base::encode_base64(she::instance()->encodeSurfaceAsPNG(surface.get()), encoded); |
| 102 | return "data:image/png;base64," + encoded; |
| 103 | } |
| 104 | |
| 105 | void putPixel(int x, int y, int color) { |
| 106 | if (unsigned(x) < unsigned(img()->width()) && unsigned(y) < unsigned(img()->height())) |
nothing calls this directly
no test coverage detected