Skip to content

Commit

Permalink
Fixed #2527: missing THUMBNAIL_BLOCK_START
Browse files Browse the repository at this point in the history
  • Loading branch information
SoftFever committed Oct 30, 2023
1 parent ca3a62f commit ac67387
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/libslic3r/GCode/Thumbnails.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,21 @@ std::string rjust(std::string input, unsigned int width, char fill_char);
std::unique_ptr<CompressedImageBuffer> compress_thumbnail(const ThumbnailData &data, GCodeThumbnailsFormat format);

template<typename WriteToOutput, typename ThrowIfCanceledCallback>
inline void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb, int plate_id, const std::vector<Vec2d> &sizes, GCodeThumbnailsFormat format, WriteToOutput output, ThrowIfCanceledCallback throw_if_canceled)
inline void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb,
int plate_id,
const std::vector<Vec2d> &sizes,
GCodeThumbnailsFormat format,
WriteToOutput output,
ThrowIfCanceledCallback throw_if_canceled)
{
// Write thumbnails using base64 encoding
if (thumbnail_cb != nullptr) {
static constexpr const size_t max_row_length = 78;
ThumbnailsList thumbnails = thumbnail_cb(ThumbnailsParams{ sizes, true, true, true, true, plate_id });
short i = 0;
for (const ThumbnailData& data : thumbnails) {
ThumbnailsList thumbnails = thumbnail_cb(ThumbnailsParams{sizes, true, true, true, true, plate_id});
short i = 0;
for (const ThumbnailData &data : thumbnails) {
if (data.is_valid()) {
output("; THUMBNAIL_BLOCK_START\n");
auto compressed = compress_thumbnail(data, format);
if (compressed->data && compressed->size) {
if (format == GCodeThumbnailsFormat::BTT_TFT) {
Expand All @@ -52,11 +58,7 @@ inline void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb,
encoded.resize(boost::beast::detail::base64::encoded_size(compressed->size));
encoded.resize(boost::beast::detail::base64::encode((void *) encoded.data(), (const void *) compressed->data,
compressed->size));

output((boost::format("\n;\n; %s begin %dx%d %d\n") % compressed->tag() % data.width % data.height % encoded.size())
.str()
.c_str());

output((boost::format("; thumbnail begin %dx%d %d\n") % data.width % data.height % encoded.size()).str().c_str());
while (encoded.size() > max_row_length) {
output((boost::format("; %s\n") % encoded.substr(0, max_row_length)).str().c_str());
encoded = encoded.substr(max_row_length);
Expand All @@ -65,10 +67,12 @@ inline void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb,
if (encoded.size() > 0)
output((boost::format("; %s\n") % encoded).str().c_str());

output((boost::format("; %s end\n;\n") % compressed->tag()).str().c_str());
output("; thumbnail end\n");
}
throw_if_canceled();
}
output("; THUMBNAIL_BLOCK_END\n\n");

i++;
}
}
Expand Down

3 comments on commit ac67387

@discip
Copy link
Contributor

@discip discip commented on ac67387 Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SoftFever
@Ocraftyone

Sorry for being late, but unfortunately this breaks the thumbnail creation for BTT TFTs.

The extra line at the beginning and between thumbnails prevents this from working.

Maybe someone could change this so that it does not apply to BTT TFT. 😅

thanks in advance
kind regards

@Rsoft1976
Copy link

@Rsoft1976 Rsoft1976 commented on ac67387 Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm, it stopped working, perhaps other printers need these settings, you need to make a selection in the program using a tick

Creality K1 needs this stock. And for separate screens these drains are not needed

@SoftFever
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be fixed in #3056

Please sign in to comment.