added greyscale
This commit is contained in:
parent
00dbd9e3cc
commit
3946c846ab
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user