57 {
58 std::vector<uint8_t> dst;
59 size_t span_len;
60 std::uint8_t pixel;
61 auto size = w * h * num_components;
62 dst.reserve(size);
63
64 const std::uint8_t *src = reinterpret_cast<const std::uint8_t *>(ptr);
65 const std::uint8_t *src_end = src +
size;
66 while (src < src_end) {
68 src += span_len;
69
70 if (pixel == 0 || pixel == 0xF0) {
71 pixel = pixel | (span_len >> 8);
72 std::copy(&pixel, (&pixel) + 1, std::back_inserter(dst));
73 pixel = span_len & 0xFF;
74 std::copy(&pixel, (&pixel) + 1, std::back_inserter(dst));
75 }
76
77 else {
78 pixel = pixel | span_len;
79 std::copy(&pixel, (&pixel) + 1, std::back_inserter(dst));
80 }
81 }
82
83 return sla::EncodedRaster(std::move(dst), "pwimg");
84 }
static void anycubicsla_get_pixel_span(const std::uint8_t *ptr, const std::uint8_t *end, std::uint8_t &pixel, size_t &span_len)
Definition AnycubicSLA.cpp:36
constexpr auto size(const C &c) -> decltype(c.size())
Definition span.hpp:183