void Framebuffer565::update(TFT *tft, int16_t x0, int16_t y0) { tft->openWindow(x0, y0, _width, _height); uint16_t buf[_width]; for (uint32_t y = 0; y < _height; y++) { getScanLine(y, 0, _width, buf); tft->windowData(buf, _width); } tft->closeWindow(); }
decltype(auto) save_image_vector_as_image(Iter first, Iter const& last, int width, boost::filesystem::path const& filepath, scalar ratio) { auto image = fipImage{FIT_BITMAP, static_cast<unsigned int>(width), static_cast<unsigned int>(width), 32}; // coordinate system of freeimage is upside down. for(auto y = static_cast<int>(width)-1; y >= 0; --y) { BYTE* row = image.getScanLine(y); for(auto x = 0; x < width; ++x) { assert(first != last); *(row+x*4) = *(row+x*4+1) = *(row+x*4+2) = ratio*(*first); ++first; } } image.save(filepath.string().c_str()); assert(first == last); }
decltype(auto) save_3ch_image_vector_as_rgb_image(Iter first, Iter const& last, int width, boost::filesystem::path const& filepath, scalar ratio) { constexpr auto channel_num = 3u; NEU_ASSERT(std::distance(first, last) == static_cast<decltype(std::distance(first, last))>(width*width*channel_num)); auto image = fipImage{FIT_BITMAP, static_cast<unsigned int>(width), static_cast<unsigned int>(width), 32}; // coordinate system of freeimage is upside down. for(auto y = static_cast<int>(width)-1; y >= 0; --y) { BYTE* row = image.getScanLine(y); for(auto x = 0; x < width; ++x) { NEU_ASSERT(first != last); *(row+x*4+0) = ratio*(*(first+0*width*width)); *(row+x*4+1) = ratio*(*(first+1*width*width)); *(row+x*4+2) = ratio*(*(first+2*width*width)); ++first; } } image.save(filepath.string().c_str()); }
void Framebuffer::getScanLine(uint16_t y, uint16_t *data) { getScanLine(y, 0, getWidth(), data); }