added greyscale

This commit is contained in:
Damian Kowalski 2024-04-06 12:45:07 +02:00
parent 00dbd9e3cc
commit 3946c846ab

View File

@ -21,11 +21,27 @@ PNM* ConversionGrayscale::transform()
if (image->format() == QImage::Format_Mono)
{
for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
QRgb pixel = image->pixel(x, y);
int gray = qGray(pixel);
newImage->setPixel(x, y, qRgb(gray, gray, gray));
}
}
}
else // if (image->format() == QImage::Format_RGB32)
{
for (int y = 0; y < height; ++y)
{
for (int x = 0; x < width; ++x)
{
QRgb pixel = image->pixel(x, y);
int gray = qGray(pixel);
newImage->setPixel(x, y, qRgb(gray, gray, gray));
}
}
}
return newImage;