Question
I've done the instructions until 7b, and the e-g. I just need help with 7c which is the mirror image. here is my codre #include
I've done the instructions until 7b, and the e-g. I just need help with 7c which is the mirror image. here is my codre
#include
// forward declarations void newImage(image in); void changeColor(pixel& p, int row, int col); void mirrorImg(image inp); int compareImg(pixel& p1, pixel& p2, int count);
int main() { int count = 0; // Read the test image test1.gif image input = ReadGIF("test1.gif"); if (input.rows == 0) { cout
// create image with different colors newImage(input); image newImage = input; // create a mirror image of the input image file mirrorImg(newImage);
// output image result WriteGIF("output.gif", newImage);
// Read the output image to a new variable image newInput = ReadGIF("output.gif");
for (int row = 0; row
cout
// wait for user input before exiting system("PAUSE"); DeallocateImage(newImage); return 0; }
void newImage(image in) { for (int row = 0; row
void changeColor(pixel& p, int row, int col) { p.blue -= (row % 7); p.red += (col % 9);
// making sure the bytes are not underflowing or overflowing if (p.blue 255) { p.blue = 255; } if (p.red 255) { p.red = 255; } }
void mirrorImg(image inp) { for (int row = 0; row
int compareImg(pixel& p1, pixel& p2, int count) { if (p1.blue != p2.blue) { count++; } else if (p1.green != p2.green) { count++; } else if (p1.red != p2.red) { count++; }
return count; }
The mirror image method is not outputting the image i want
2. Create a new C++ project in Visual Studio called "Program1". The project should and Empty C++ Project. If your project has stdafx.h or targetver.h, then you did this incorrectly. Your code should compile without these files and you should not turn them in. Remember where you save the project. 3. Download the following files and place them in .../Program 1/Program 1/: ImageLib.h , ImageLib.lib, ImageLib.pdb, test1.gif. You should not change the contents of these files in order to complete the assignment. 4. Examine ImageLib.h in order to understand the interface for reading and writing GIF images. You should not be able to access the implementation details of ImageLib.lib (this is abstraction, I am hiding the details). Note that images are not first-class objects. For example, there is no copy constructor or assignment operator that performs a deep copy. Functions are provided in the library for these purposes. 5. Add Imagelib.h and ImageLib.lib to your project. (Project - Add Existing Item.) 6. Create a new source file in Program1 called main.cpp (Project - Add Existing Item). We are now ready to start coding. 7. Edit main.cpp to accomplish the following in order: a. Read the image test1.gif. b. For every pixel of this image: i. Subtract row mod 7 from the blue component of the pixel, where row is the row of the current pixel. The mod operator uses the % symbol. ii. Add col mod 9 to the red component of the pixel, col is the column of the current pixel. iii. The green component should be unchanged. iv. As you are doing this, make sure to check for overflow and underflow, since bytes are unable to store values below 0 or above 255. If you find overflow, set the byte to 255. If you find underflow, set the byte to 0. c. Create a new image that is the mirror-image of the image from the previous step. (The left side and the right side are reversed.) d. Save the new image to a file called output.gif. e. Read output.gif back into a new image variable. f. Compare each pixel in the newly read image to the one that you saved in step d (not the original). Are there any differences? g. Count and output to the console the number of pixels that have a different values in red, green, or blue. (If a pixel has a difference in any of the three values, then that pixels counts once toward the count. A pixel cannot count more than once.) 8. Submit your completed code (only new code that you wrote, probably just main.cpp) in CanvasStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started