mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 18:27:58 -06:00
Fixed #2527: missing THUMBNAIL_BLOCK_START
This commit is contained in:
parent
ca3a62fba8
commit
ac67387c7d
1 changed files with 14 additions and 10 deletions
|
@ -30,7 +30,12 @@ std::string rjust(std::string input, unsigned int width, char fill_char);
|
||||||
std::unique_ptr<CompressedImageBuffer> compress_thumbnail(const ThumbnailData &data, GCodeThumbnailsFormat format);
|
std::unique_ptr<CompressedImageBuffer> compress_thumbnail(const ThumbnailData &data, GCodeThumbnailsFormat format);
|
||||||
|
|
||||||
template<typename WriteToOutput, typename ThrowIfCanceledCallback>
|
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
|
// Write thumbnails using base64 encoding
|
||||||
if (thumbnail_cb != nullptr) {
|
if (thumbnail_cb != nullptr) {
|
||||||
|
@ -39,6 +44,7 @@ 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) {
|
||||||
|
@ -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::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,
|
||||||
compressed->size));
|
compressed->size));
|
||||||
|
output((boost::format("; thumbnail begin %dx%d %d\n") % data.width % data.height % encoded.size()).str().c_str());
|
||||||
output((boost::format("\n;\n; %s begin %dx%d %d\n") % compressed->tag() % data.width % data.height % encoded.size())
|
|
||||||
.str()
|
|
||||||
.c_str());
|
|
||||||
|
|
||||||
while (encoded.size() > max_row_length) {
|
while (encoded.size() > max_row_length) {
|
||||||
output((boost::format("; %s\n") % encoded.substr(0, max_row_length)).str().c_str());
|
output((boost::format("; %s\n") % encoded.substr(0, max_row_length)).str().c_str());
|
||||||
encoded = encoded.substr(max_row_length);
|
encoded = encoded.substr(max_row_length);
|
||||||
|
@ -65,10 +67,12 @@ inline void export_thumbnails_to_file(ThumbnailsGeneratorCallback &thumbnail_cb,
|
||||||
if (encoded.size() > 0)
|
if (encoded.size() > 0)
|
||||||
output((boost::format("; %s\n") % encoded).str().c_str());
|
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();
|
throw_if_canceled();
|
||||||
}
|
}
|
||||||
|
output("; THUMBNAIL_BLOCK_END\n\n");
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue