-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfilters.cpp
More file actions
executable file
·44 lines (37 loc) · 1.29 KB
/
filters.cpp
File metadata and controls
executable file
·44 lines (37 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "filters.h"
Filters::Filters()
{
}
/*
* SERIAL IMPLEMENTATIONS
*/
/*
* ---------------------------------------------------------------------------------
* BLACK AND WHITE - SERIAL
* ---------------------------------------------------------------------------------
* Directly modifies the given QPixmap object, desaturating each pixel of the object
* to produce a black and white representation (serial implementation)
*
* @param QPixmap image : the QPixmap object we wish to convert
* @return QPixmap : the edited QPixmap object
* ---------------------------------------------------------------------------------
*/
QImage Filters::serialFilterBlackWhite(QImage image)
{
// Convert our Pixmap object to an image so we can manipulate the pixel data.
QRgb currentColor;
int gray;
// Loop through each pixel, getting the current RGB values as grayscale using qGray
// then set the new value of the image using qRgb
for(int i = 0; i < image.width(); i++)
{
for(int j = 0; j < image.height(); j++)
{
currentColor = image.pixel(i , j);
gray = qGray(currentColor);
image.setPixel(i, j, qRgb(gray, gray, gray));
}
}
// Convert the QImage object back to a QPixmap and return it
return image;
}