|
@@ -108,27 +108,26 @@ The following functions are useful to work with data of type `QRgb`:
|
108
|
108
|
3. The following program creates an object of class `QImage` and prints the red, green and blue components of the pixel in the center of the image. The image used is the one specified within the parenthesis during the creation of the object, that is, the file `chuck.png`.
|
109
|
109
|
|
110
|
110
|
---
|
111
|
|
-
|
112
|
|
- ```cpp
|
113
|
|
- #include <QImage>
|
114
|
|
- #include <iostream>
|
115
|
|
-
|
116
|
|
- using namespace std;
|
117
|
|
- int main() {
|
118
|
|
- QImage myImage(“/Users/rarce/Downloads/chuck.png”);
|
119
|
|
- QRgb centralPixel;
|
120
|
|
-
|
121
|
|
- centralPixel = myImage.pixel(myImage.width() / 2, myImage.height() / 2);
|
122
|
|
-
|
123
|
|
- cout << hex;
|
124
|
|
-
|
125
|
|
- cout << “The red, green and blue components of the middle pixel are: “
|
126
|
|
- << qRed(centralPixel) << “, “
|
127
|
|
- << qGreen(centralPixel) << “, “
|
128
|
|
- << qBlue(centralPixel) << endl;
|
129
|
|
- return 0;
|
130
|
|
- }
|
131
|
|
- ```
|
|
111
|
+
|
|
112
|
+ #include <QImage>
|
|
113
|
+ #include <iostream>
|
|
114
|
+
|
|
115
|
+ using namespace std;
|
|
116
|
+ int main() {
|
|
117
|
+ QImage myImage(“/Users/rarce/Downloads/chuck.png”);
|
|
118
|
+ QRgb centralPixel;
|
|
119
|
+
|
|
120
|
+ centralPixel = myImage.pixel(myImage.width() / 2, myImage.height() / 2);
|
|
121
|
+
|
|
122
|
+ cout << hex;
|
|
123
|
+
|
|
124
|
+ cout << “The red, green and blue components of the middle pixel are: “
|
|
125
|
+ << qRed(centralPixel) << “, “
|
|
126
|
+ << qGreen(centralPixel) << “, “
|
|
127
|
+ << qBlue(centralPixel) << endl;
|
|
128
|
+ return 0;
|
|
129
|
+ }
|
|
130
|
+
|
132
|
131
|
|
133
|
132
|
---
|
134
|
133
|
|