Fix btt tft thumbnail regression (#3056)

fix btt tft thumbnail regression
This commit is contained in:
SoftFever 2023-12-10 09:56:40 +08:00 committed by GitHub
parent 933aa3050b
commit b218d81d38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -44,7 +44,6 @@ inline void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb,
short i = 0; short i = 0;
for (const ThumbnailData &data : thumbnails) { for (const ThumbnailData &data : thumbnails) {
if (data.is_valid()) { if (data.is_valid()) {
output("; THUMBNAIL_BLOCK_START\n");
auto compressed = compress_thumbnail(data, format); auto compressed = compress_thumbnail(data, format);
if (compressed->data && compressed->size) { if (compressed->data && compressed->size) {
if (format == GCodeThumbnailsFormat::BTT_TFT) { if (format == GCodeThumbnailsFormat::BTT_TFT) {
@ -54,6 +53,7 @@ inline void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb,
if (i == (thumbnails.size() - 1)) if (i == (thumbnails.size() - 1))
output("; bigtree thumbnail end\r\n\r\n"); output("; bigtree thumbnail end\r\n\r\n");
} else { } else {
output("; THUMBNAIL_BLOCK_START\n");
std::string encoded; std::string encoded;
encoded.resize(boost::beast::detail::base64::encoded_size(compressed->size)); encoded.resize(boost::beast::detail::base64::encoded_size(compressed->size));
encoded.resize(boost::beast::detail::base64::encode((void *) encoded.data(), (const void *) compressed->data, encoded.resize(boost::beast::detail::base64::encode((void *) encoded.data(), (const void *) compressed->data,
@ -71,10 +71,10 @@ inline void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb,
output((boost::format("; %s\n") % encoded).str().c_str()); output((boost::format("; %s\n") % encoded).str().c_str());
output((boost::format("; %s end\n") % compressed->tag()).str().c_str()); output((boost::format("; %s end\n") % compressed->tag()).str().c_str());
output("; THUMBNAIL_BLOCK_END\n\n");
} }
throw_if_canceled(); throw_if_canceled();
} }
output("; THUMBNAIL_BLOCK_END\n\n");
i++; i++;
} }