Skip to content

Commit

Permalink
Added possibility of customizating the dummy texture used to show the…
Browse files Browse the repository at this point in the history
… parametrization
  • Loading branch information
cignoni committed Nov 14, 2024
1 parent b1f8c42 commit c109500
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
32 changes: 30 additions & 2 deletions src/common/utilities/load_save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/common/utilities/load_save.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c109500

Please sign in to comment.