diff --git a/src/core/transformations/conversion_grayscale.cpp b/src/core/transformations/conversion_grayscale.cpp index 7cc66cb..28e5f50 100644 --- a/src/core/transformations/conversion_grayscale.cpp +++ b/src/core/transformations/conversion_grayscale.cpp @@ -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;