Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below is the header files for the ImageLib.h The test image file can be anything. the .lib and .pdb files has things in it that

image text in transcribed

Below is the header files for the ImageLib.h

image text in transcribed

image text in transcribed

The test image file can be anything. the .lib and .pdb files has things in it that I don't understand at all. I will post a screenshot about it below.

image text in transcribed

If you don't need to use the pre-defined files to build the class, that's fine as well. I can change the code that uses the pre-defined files later. But please comment on code that will be similar to the heading files that I gave. For example, there is a constructor that ask us to use a filename. if the class is ImageLib, the constructor would be something like ImageLib(ReadGIF(string filename)).

C++ Language. If possible, explain why you did what you did.

Thanks!

You are to create a new class representing images. Remember that your project should be created as an "Empty project," so that you don't get precompiled header code among other things. In order to create this class you should continue to use the files for working with images from the previous programming assignment: ImageLib.h , ImageLib.lib, ImageLib.pdb. Here is a new test image: test2.gif The assignment has two parts. First, you will play the role of class designer and create a new class for images. Second, you will play the role of developer using the class you wrote. For the second part, you should use your class, but not make any assumptions about the implementation of the class (and don't write new member operations to solve that part). Your image class should include (at least) the following capabilities. Use my image library as much as possible to make these simple. For example, store an image variable in your private data. Use Read GIF to implement the first constructor, etc. Constructor using a filename (read from a file) Constructor using just the number of rows and columns (create a blank, black image) Copy constructor, destructor, operator= (these are important, since ImageLib uses dynamic memory!) Accessors for the number of rows and columns in the image Accessor and mutator functions for individual image pixels Output to a file Overload the == and != operator for comparison of images (every pixel must be the same) Overload the > and using namespace std; /* * Type definitions typedef unsigned char byte; // A single byte of data typedef struct { byte red; byte green; byte blue; } pixel; I/ A pixel stores 3 bytes of data: // intensity of the red component // intensity of the green component // intensity of the blue component // // A simple image data structure: // rows is the height of the image (the number of rows of pixels) // cols is the width of the image (the number of columns of pixels) // pixels is a 2D array of the image pixels The first dimension of pixels varies from oto rows-1 The second dimension of pixels varies from o to cols-1 The pixel at row i and column j is accessed by pixels[i][j] With the following definition: // image myimage; // We could access the red component of the pixel at row 10, column 20 by: // myimage.pixels[10] [20].red typedef struct { int rows, cols; /* pic size */ pixel **pixels; /* image data */ } image; * Function prototypes */ * ReadGIF: Preconditions: filename refers to a file that stores a GIF image. Post conditions: returns the image contained in "filename" using the conventions described for the image type above. If the load is unsuccessful, returns an image with rows = 0, cols = 0, pixels = nullptr. image ReadGIF(string filename); WriteGIF: - Preconditions: filename is valid filename to store a GIF image. input Image holds an image using the conventions described for the image type above. * Postconditions: input Image is saved as a GIF image at the location specified by filename. void WriteGIF(string filename, image input Image); Deal locateImage: Preconditions: input Image contains an image using the conventions for the image type described above. * Postconditions: the memory allocated to the pixels of input Image has been deallocated. Also, the image values are set to: rows = 0, cols = 0, pixels = nullptr. void DeallocateImage image &input Image); Copy Image: * Preconditions: input Image contains an image using the conventions for the image type described above. Postconditions: if sufficient memory is available, a copy of input Image is returned using newly allocated memory. Otherwise, the returned image has: rows = 0, cols=@, pixels = nullptr. image Copy Image(image input Image); * CreateImage: * Preconditions: rows and cols describe the desired size of the new image. * Postconditions: if sufficient memory is available, a new image is returned using newly allocated memory. Each pixel has red = @, green -e, blue = e. Otherwise, the returned image has: rows = @, cols =0, pixels = nullptr. image CreateImage(int rows, int cols); File Edit View Tools Window Help Search (Ctrl+Q), Project Build . 2- Debug Debug Test Analyze - x86 Extensions Attach.... LO S Server Explorer Toolbox ImageLib.lib + x main.cpp 00000000 21 3C 61 72 63 68 3E OA 2F 20 20 20 20 20 20 20 !/ 00000010 20 20 20 20 20 20 20 20 31 35 30 37 33 31 39 34 15073194 00000020 34 31 20 20 20 20 20 20 20 20 20 20 20 20 20 20 41 00000030 30 20 20 20 20 20 20 20 36 32 33 34 20 20 20 20 0 6 234 00000040 20 20 60 OA 00 00 00 7B 0000 30 96 00 00 30 96 .... ..0...0. 00000050 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000060 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000070 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000080 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000090 00 00 30 96 00 00 30 96 0000 30 96 00 00 30 96 ..0...0...0...0. 00000000000 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 000000b0 00 00 30 96 00 00 30 96 0000 30 96 00 00 30 96 ..0...0...0...0. 000000c0 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 000000do 00 00 30 96 00 00 30 96 0000 30 96 00 00 30 96 ..0...0...0...0. 000000e0 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0. 000000f0 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000100 00 00 30 96 00 00 30 96 0000 30 96 00 00 30 96 ..0...0...0...0. 00000110 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000120 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000130 00 00 30 96 00 00 30 96 0000 30 96 00 00 30 96 ..0...0...0...0. 00000140 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000150 00 00 30 96 00 00 30 96 0000 30 96 00 00 30 96 ..0...0...0...0. 00000160 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000170 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000180 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000190 00 00 30 96 00 00 30 96 0000 30 96 00 00 30 96 ..0...0...0...0. 000001a0 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000160 00 00 30 96 00 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 000001c0 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0. 00000100 00 00 30 96 00 00 30 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000100 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000160 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. You are to create a new class representing images. Remember that your project should be created as an "Empty project," so that you don't get precompiled header code among other things. In order to create this class you should continue to use the files for working with images from the previous programming assignment: ImageLib.h , ImageLib.lib, ImageLib.pdb. Here is a new test image: test2.gif The assignment has two parts. First, you will play the role of class designer and create a new class for images. Second, you will play the role of developer using the class you wrote. For the second part, you should use your class, but not make any assumptions about the implementation of the class (and don't write new member operations to solve that part). Your image class should include (at least) the following capabilities. Use my image library as much as possible to make these simple. For example, store an image variable in your private data. Use Read GIF to implement the first constructor, etc. Constructor using a filename (read from a file) Constructor using just the number of rows and columns (create a blank, black image) Copy constructor, destructor, operator= (these are important, since ImageLib uses dynamic memory!) Accessors for the number of rows and columns in the image Accessor and mutator functions for individual image pixels Output to a file Overload the == and != operator for comparison of images (every pixel must be the same) Overload the > and using namespace std; /* * Type definitions typedef unsigned char byte; // A single byte of data typedef struct { byte red; byte green; byte blue; } pixel; I/ A pixel stores 3 bytes of data: // intensity of the red component // intensity of the green component // intensity of the blue component // // A simple image data structure: // rows is the height of the image (the number of rows of pixels) // cols is the width of the image (the number of columns of pixels) // pixels is a 2D array of the image pixels The first dimension of pixels varies from oto rows-1 The second dimension of pixels varies from o to cols-1 The pixel at row i and column j is accessed by pixels[i][j] With the following definition: // image myimage; // We could access the red component of the pixel at row 10, column 20 by: // myimage.pixels[10] [20].red typedef struct { int rows, cols; /* pic size */ pixel **pixels; /* image data */ } image; * Function prototypes */ * ReadGIF: Preconditions: filename refers to a file that stores a GIF image. Post conditions: returns the image contained in "filename" using the conventions described for the image type above. If the load is unsuccessful, returns an image with rows = 0, cols = 0, pixels = nullptr. image ReadGIF(string filename); WriteGIF: - Preconditions: filename is valid filename to store a GIF image. input Image holds an image using the conventions described for the image type above. * Postconditions: input Image is saved as a GIF image at the location specified by filename. void WriteGIF(string filename, image input Image); Deal locateImage: Preconditions: input Image contains an image using the conventions for the image type described above. * Postconditions: the memory allocated to the pixels of input Image has been deallocated. Also, the image values are set to: rows = 0, cols = 0, pixels = nullptr. void DeallocateImage image &input Image); Copy Image: * Preconditions: input Image contains an image using the conventions for the image type described above. Postconditions: if sufficient memory is available, a copy of input Image is returned using newly allocated memory. Otherwise, the returned image has: rows = 0, cols=@, pixels = nullptr. image Copy Image(image input Image); * CreateImage: * Preconditions: rows and cols describe the desired size of the new image. * Postconditions: if sufficient memory is available, a new image is returned using newly allocated memory. Each pixel has red = @, green -e, blue = e. Otherwise, the returned image has: rows = @, cols =0, pixels = nullptr. image CreateImage(int rows, int cols); File Edit View Tools Window Help Search (Ctrl+Q), Project Build . 2- Debug Debug Test Analyze - x86 Extensions Attach.... LO S Server Explorer Toolbox ImageLib.lib + x main.cpp 00000000 21 3C 61 72 63 68 3E OA 2F 20 20 20 20 20 20 20 !/ 00000010 20 20 20 20 20 20 20 20 31 35 30 37 33 31 39 34 15073194 00000020 34 31 20 20 20 20 20 20 20 20 20 20 20 20 20 20 41 00000030 30 20 20 20 20 20 20 20 36 32 33 34 20 20 20 20 0 6 234 00000040 20 20 60 OA 00 00 00 7B 0000 30 96 00 00 30 96 .... ..0...0. 00000050 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000060 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000070 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000080 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000090 00 00 30 96 00 00 30 96 0000 30 96 00 00 30 96 ..0...0...0...0. 00000000000 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 000000b0 00 00 30 96 00 00 30 96 0000 30 96 00 00 30 96 ..0...0...0...0. 000000c0 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 000000do 00 00 30 96 00 00 30 96 0000 30 96 00 00 30 96 ..0...0...0...0. 000000e0 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0. 000000f0 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000100 00 00 30 96 00 00 30 96 0000 30 96 00 00 30 96 ..0...0...0...0. 00000110 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000120 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000130 00 00 30 96 00 00 30 96 0000 30 96 00 00 30 96 ..0...0...0...0. 00000140 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000150 00 00 30 96 00 00 30 96 0000 30 96 00 00 30 96 ..0...0...0...0. 00000160 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000170 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000180 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000190 00 00 30 96 00 00 30 96 0000 30 96 00 00 30 96 ..0...0...0...0. 000001a0 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000160 00 00 30 96 00 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 000001c0 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0. 00000100 00 00 30 96 00 00 30 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000100 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0. 00000160 00 00 30 96 00 00 30 96 00 00 30 96 00 00 30 96 ..0...0...0...0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Structure Of The Relational Database Model

Authors: Jan Paredaens ,Paul De Bra ,Marc Gyssens ,Dirk Van Gucht

1st Edition

3642699588, 978-3642699580

More Books

Students also viewed these Databases questions

Question

assess the infl uence of national culture on the workplace

Answered: 1 week ago