From c109500403f8eaaee34aa0ab882ad6126e1a9217 Mon Sep 17 00:00:00 2001 From: Paolo Cignoni Date: Thu, 14 Nov 2024 10:23:07 +0100 Subject: [PATCH] Added possibility of customizating the dummy texture used to show the parametrization --- src/common/utilities/load_save.cpp | 32 ++++++++++++++++++++++++++++-- src/common/utilities/load_save.h | 2 +- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/common/utilities/load_save.cpp b/src/common/utilities/load_save.cpp index 5ce951f8ce..dce421538d 100644 --- a/src/common/utilities/load_save.cpp +++ b/src/common/utilities/load_save.cpp @@ -333,9 +333,37 @@ QImage loadImage(const QString& filename, GLLogStream* log, vcg::CallBackPos* cb } } -QImage getDummyTexture() +QImage getDummyTexture(int imageSize, int checkSize, bool gridFlag) { - return QImage(":/resources/images/dummy.png"); + QImage image(imageSize, imageSize, QImage::Format_RGB32); + if(gridFlag) + { + for (int y = 0; y < imageSize; ++y) { + for (int x = 0; x < imageSize; ++x) { + if ( ((x/checkSize) %2 ) == ((y/checkSize) % 2)) { + image.setPixel(x, y, 0xFFFFFF); + } else { + image.setPixel(x, y, 0x808080); + } + } + } + } + else + { + for (int y = 0; y < imageSize; ++y) { + for (int x = 0; x < imageSize; ++x) { + if ( (x%checkSize) == 0 || (y%checkSize) == 0) + image.setPixel(x, y, 0xFFFFFF); + else + image.setPixel(x, y, 0x808080); + } + } + } + // Save the image to a file. + image.save("checkerboard.png"); + + return image; + // QImage(":/resources/images/dummy.png"); } void saveImage( diff --git a/src/common/utilities/load_save.h b/src/common/utilities/load_save.h index cfc28a28fb..faf2b8b98e 100644 --- a/src/common/utilities/load_save.h +++ b/src/common/utilities/load_save.h @@ -70,7 +70,7 @@ void saveAllMeshes( QImage loadImage(const QString& filename, GLLogStream* log = nullptr, vcg::CallBackPos* cb = nullptr); -QImage getDummyTexture(); +QImage getDummyTexture(int size=512, int checkNum=8, bool gridFlag=false); void saveImage( const QString& filename,