ENABLE_THUMBNAIL_GENERATOR -> ENABLE_THUMBNAIL_GENERATOR_PNG_TO_GCODE set as default

This commit is contained in:
Enrico Turri 2019-11-25 10:30:31 +01:00
parent 2b17e81f13
commit b1047d2e26
3 changed files with 0 additions and 88 deletions

View File

@ -32,9 +32,7 @@
#include <Shiny/Shiny.h>
#if ENABLE_THUMBNAIL_GENERATOR_PNG_TO_GCODE
#include "miniz_extension.hpp"
#endif // ENABLE_THUMBNAIL_GENERATOR_PNG_TO_GCODE
#if 0
// Enable debugging and asserts, even in the release build.
@ -998,7 +996,6 @@ void GCode::_do_export(Print& print, FILE* file)
{
if (data.is_valid())
{
#if ENABLE_THUMBNAIL_GENERATOR_PNG_TO_GCODE
size_t png_size = 0;
void* png_data = tdefl_write_image_to_png_file_in_memory_ex((const void*)data.pixels.data(), data.width, data.height, 4, &png_size, MZ_DEFAULT_LEVEL, 1);
if (png_data != nullptr)
@ -1024,39 +1021,6 @@ void GCode::_do_export(Print& print, FILE* file)
mz_free(png_data);
}
#else
_write_format(file, "\n;\n; thumbnail begin %dx%d\n", data.width, data.height);
size_t row_size = 4 * data.width;
for (int r = (int)data.height - 1; r >= 0; --r)
{
std::string encoded;
encoded.resize(boost::beast::detail::base64::encoded_size(row_size));
encoded.resize(boost::beast::detail::base64::encode((void*)&encoded[0], (const void*)(data.pixels.data() + r * row_size), row_size));
unsigned int row_count = 0;
while (encoded.size() > max_row_length)
{
if (row_count == 0)
_write_format(file, "; %s\n", encoded.substr(0, max_row_length).c_str());
else
_write_format(file, ";>%s\n", encoded.substr(0, max_row_length).c_str());
encoded = encoded.substr(max_row_length);
++row_count;
}
if (encoded.size() > 0)
{
if (row_count == 0)
_write_format(file, "; %s\n", encoded.c_str());
else
_write_format(file, ";>%s\n", encoded.c_str());
}
}
_write(file, "; thumbnail end\n;\n");
#endif // ENABLE_THUMBNAIL_GENERATOR_PNG_TO_GCODE
}
print.throw_if_canceled();
}

View File

@ -40,7 +40,6 @@
// Enable thumbnail generator
#define ENABLE_THUMBNAIL_GENERATOR (1 && ENABLE_2_2_0_ALPHA1)
#define ENABLE_THUMBNAIL_GENERATOR_DEBUG (0 && ENABLE_THUMBNAIL_GENERATOR)
#define ENABLE_THUMBNAIL_GENERATOR_PNG_TO_GCODE (1 && ENABLE_THUMBNAIL_GENERATOR)
// Enable adaptive layer height profile
#define ENABLE_ADAPTIVE_LAYER_HEIGHT_PROFILE (1 && ENABLE_2_2_0_ALPHA1)

View File

@ -1126,7 +1126,6 @@ void GUI_App::gcode_thumbnails_debug()
}
else if (reading_image && boost::starts_with(gcode_line, END_MASK))
{
#if ENABLE_THUMBNAIL_GENERATOR_PNG_TO_GCODE
std::string out_filename = out_path + std::to_string(width) + "x" + std::to_string(height) + ".png";
boost::nowide::ofstream out_file(out_filename.c_str(), std::ios::binary);
if (out_file.good())
@ -1138,46 +1137,6 @@ void GUI_App::gcode_thumbnails_debug()
out_file.write(decoded.c_str(), decoded.size());
out_file.close();
}
#else
if (!row.empty())
{
rows.push_back(row);
row.clear();
}
if ((unsigned int)rows.size() == height)
{
std::vector<unsigned char> thumbnail(4 * width * height, 0);
for (unsigned int r = 0; r < (unsigned int)rows.size(); ++r)
{
std::string decoded_row;
decoded_row.resize(boost::beast::detail::base64::decoded_size(rows[r].size()));
decoded_row.resize(boost::beast::detail::base64::decode((void*)&decoded_row[0], rows[r].data(), rows[r].size()).first);
if ((unsigned int)decoded_row.size() == width * 4)
{
void* image_ptr = (void*)(thumbnail.data() + r * width * 4);
::memcpy(image_ptr, (const void*)decoded_row.c_str(), width * 4);
}
}
wxImage image(width, height);
image.InitAlpha();
for (unsigned int r = 0; r < height; ++r)
{
unsigned int rr = r * width;
for (unsigned int c = 0; c < width; ++c)
{
unsigned char* px = thumbnail.data() + 4 * (rr + c);
image.SetRGB((int)c, (int)r, px[0], px[1], px[2]);
image.SetAlpha((int)c, (int)r, px[3]);
}
}
image.SaveFile(out_path + std::to_string(width) + "x" + std::to_string(height) + ".png", wxBITMAP_TYPE_PNG);
}
#endif // ENABLE_THUMBNAIL_GENERATOR_PNG_TO_GCODE
reading_image = false;
width = 0;
@ -1185,17 +1144,7 @@ void GUI_App::gcode_thumbnails_debug()
rows.clear();
}
else if (reading_image)
{
#if !ENABLE_THUMBNAIL_GENERATOR_PNG_TO_GCODE
if (!row.empty() && (gcode_line[1] == ' '))
{
rows.push_back(row);
row.clear();
}
#endif // !ENABLE_THUMBNAIL_GENERATOR_PNG_TO_GCODE
row += gcode_line.substr(2);
}
}
}