ENABLE_THUMBNAIL_GENERATOR -> WIP: Refactoring and preparation for adding thumbnails to exported gcode and 3mf files

This commit is contained in:
Enrico Turri 2019-10-23 13:31:24 +02:00
parent 959ef9a9ec
commit 4d1153c866
15 changed files with 346 additions and 46 deletions

View file

@ -7,16 +7,16 @@ namespace Slic3r {
void ThumbnailData::set(unsigned int w, unsigned int h)
{
if (!pixels.empty())
reset();
if ((w == 0) || (h == 0))
return;
width = w;
height = h;
// defaults to white texture
pixels = std::vector<unsigned char>(width * height * 4, 255);
if ((width != w) || (height != h))
{
width = w;
height = h;
// defaults to white texture
pixels = std::vector<unsigned char>(width * height * 4, 255);
}
}
void ThumbnailData::reset()
@ -26,6 +26,11 @@ void ThumbnailData::reset()
pixels.clear();
}
bool ThumbnailData::is_valid() const
{
return (width != 0) && (height != 0) && ((unsigned int)pixels.size() == 4 * width * height);
}
} // namespace Slic3r
#endif // ENABLE_THUMBNAIL_GENERATOR