MP 2
Image Manipulation II
Image Class Reference

A subclass of PNG with more member functions for modifying the image. More...

#include "image.h"

+ Inheritance diagram for Image:
+ Collaboration diagram for Image:

Public Member Functions

void flipleft ()
 Flips the image about a vertical line through its center by swapping pixels. More...
 
void adjustbrightness (int r, int g, int b)
 Adds to the red, green, and blue parts of each pixel in the image. More...
 
void invertcolors ()
 Makes each RGB component of each pixel iequal to 255 minus its original value. More...
 
- Public Member Functions inherited from PNG
 PNG ()
 Creates a default PNG image (that is, a 1x1 opaque white image). More...
 
 PNG (size_t width, size_t height)
 Creates a default PNG image of the desired dimensions (that is, a width x height opaque white image). More...
 
 PNG (string const &file_name)
 Creates a PNG image by reading a file in from disk. More...
 
 PNG (PNG const &other)
 Copy constructor: creates a new PNG image that is a copy of another. More...
 
 ~PNG ()
 Destructor: frees all memory associated with a given PNG object. More...
 
PNG const & operator= (PNG const &other)
 Assignment operator for setting two PNGs equal to one another. More...
 
bool operator== (PNG const &other) const
 Equality operator: checks if two images are the same. More...
 
bool operator!= (PNG const &other) const
 Inequality operator: checks if two images are different. More...
 
RGBAPixeloperator() (size_t x, size_t y)
 Non-const pixel access operator. More...
 
RGBAPixel const * operator() (size_t x, size_t y) const
 Const pixel access operator. More...
 
bool readFromFile (string const &file_name)
 Reads in a PNG image from a file. More...
 
bool writeToFile (string const &file_name)
 Writes a PNG image to a file. More...
 
size_t width () const
 Gets the width of this image. More...
 
size_t height () const
 Gets the height of this image. More...
 
void resize (size_t width, size_t height)
 Resizes the image to the given coordinates. More...
 

Detailed Description

A subclass of PNG with more member functions for modifying the image.

Member Function Documentation

void Image::flipleft ( )

Flips the image about a vertical line through its center by swapping pixels.

Note
You must implement this function with space efficiency. That is, you should not declare a new empty Image into which you copy pixels. Rather, you should just use a temporary variable to swap pixels within the original Image.
void Image::adjustbrightness ( int  r,
int  g,
int  b 
)

Adds to the red, green, and blue parts of each pixel in the image.

Parameters
rthe amount to adjust the red value by
gthe amount to adjust the green value by
bthe amount to adjust the blue value by
Note
Overflow is prevented: if the result would be less than 0, it is 0. If the result would be greater than 255, it is 255.
void Image::invertcolors ( )

Makes each RGB component of each pixel iequal to 255 minus its original value.

That is, the colors become the opposite of what they were, makeing a color-opposite of the original image.


The documentation for this class was generated from the following files: