Please provide appropriate comments explaining what is being done on the lines of the code below. The code uses a 2-D array for storing an image pixmap. 1 struct pixel { 2 3 4 5 pixel **pixmap; 6 unsigned int W, H; 7 8 13 14 15 16 }; 9 pixmap = new pixel* [H]; 10 pixmap [0] = new pixel [W* H); for (int i = 1; i < H; i++) 11 12 17 18 19 20 unsigned char r, g, b; 21 pixmap[i] = pixmap [i 1] + W; //.... assume we read some image file and stored it in pixmap for (int row = 0; row

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question
Please give me correct solution.
Please provide appropriate comments explaining what is being done on the lines of the code
below. The code uses a 2-D array for storing an image pixmap.
1
2
3
4
5 pixel **pixmap;
6 unsigned int W, H;
7
struct pixel {
13
14
15
16
17
18
19
20
21
};
8
9
pixmap = new pixel* [H] ;
10 pixmap [0] = new pixel [W * H];
11
for (int i = 1; i < H; i++)
12
pixmap [i] = pixmap[i - 1] + W;
//.... assume we read some image file and stored it in pixmap
for (int row = 0; row <H; row++)
for (int col = 0; col < W; col++) {
unsigned char r, g, b;
}
pixmap[row] [col].r 255 pixmap [row] [col].r;
pixmap [row] [col].g = 255 - pixmap [row] [col].g;
pixmap[row] [col].b = 255 pixmap [row] [col].b;
Transcribed Image Text:Please provide appropriate comments explaining what is being done on the lines of the code below. The code uses a 2-D array for storing an image pixmap. 1 2 3 4 5 pixel **pixmap; 6 unsigned int W, H; 7 struct pixel { 13 14 15 16 17 18 19 20 21 }; 8 9 pixmap = new pixel* [H] ; 10 pixmap [0] = new pixel [W * H]; 11 for (int i = 1; i < H; i++) 12 pixmap [i] = pixmap[i - 1] + W; //.... assume we read some image file and stored it in pixmap for (int row = 0; row <H; row++) for (int col = 0; col < W; col++) { unsigned char r, g, b; } pixmap[row] [col].r 255 pixmap [row] [col].r; pixmap [row] [col].g = 255 - pixmap [row] [col].g; pixmap[row] [col].b = 255 pixmap [row] [col].b;
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Image Element
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage