Represents an entire png formatted image.
More...
#include "png.h"
Represents an entire png formatted image.
Creates a default PNG image (that is, a 1x1 opaque white image).
PNG::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).
- Parameters
-
width | Width of the new image. |
height | Height of the new image. |
PNG::PNG |
( |
string const & |
file_name | ) |
|
Creates a PNG image by reading a file in from disk.
- Parameters
-
file_name | Name of the file to be read in to the image. |
PNG::PNG |
( |
PNG const & |
other | ) |
|
Copy constructor: creates a new PNG image that is a copy of another.
- Parameters
-
Destructor: frees all memory associated with a given PNG object.
Invoked by the system.
PNG const & PNG::operator= |
( |
PNG const & |
other | ) |
|
Assignment operator for setting two PNGs equal to one another.
- Parameters
-
other | Image to copy into the current image. |
- Returns
- The current image for assignment chaining.
bool PNG::operator== |
( |
PNG const & |
other | ) |
const |
Equality operator: checks if two images are the same.
- Parameters
-
other | Image to be checked. |
- Returns
- Whether the current image is equal to the other image.
bool PNG::operator!= |
( |
PNG const & |
other | ) |
const |
Inequality operator: checks if two images are different.
- Parameters
-
other | Image to be checked. |
- Returns
- Whether the current image differs from the other image.
RGBAPixel * PNG::operator() |
( |
size_t |
x, |
|
|
size_t |
y |
|
) |
| |
Non-const pixel access operator.
Gets a pointer to the pixel at the given coordinates in the image. (0,0) is the upper left corner. This pointer allows the image to be changed.
- Parameters
-
x | X-coordinate for the pixel pointer to be grabbed from. |
y | Y-coordinate for the pixel pointer to be grabbed from. |
- Returns
- A pointer to the pixel at the given coordinates.
RGBAPixel const * PNG::operator() |
( |
size_t |
x, |
|
|
size_t |
y |
|
) |
| const |
Const pixel access operator.
Const version of the previous operator(). Does not allow the image to be changed via the pointer.
- Parameters
-
x | X-coordinate for the pixel pointer to be grabbed from. |
y | Y-cooridnate for the pixel pointer to be grabbed from. |
- Returns
- A pointer to the pixel at the given coordinates (can't change the pixel through this pointer).
bool PNG::readFromFile |
( |
string const & |
file_name | ) |
|
Reads in a PNG image from a file.
Overwrites any current image content in the PNG. In the event of failure, the image's contents are undefined.
- Parameters
-
file_name | Name of the file to be read from. |
- Returns
- Whether the image was successfully read in or not.
bool PNG::writeToFile |
( |
string const & |
file_name | ) |
|
Writes a PNG image to a file.
- Parameters
-
file_name | Name of the file to write to. |
- Returns
- Whether the file was written successfully or not.
size_t PNG::width |
( |
| ) |
const |
Gets the width of this image.
- Returns
- Width of the image.
size_t PNG::height |
( |
| ) |
const |
Gets the height of this image.
- Returns
- Height of the image.
void PNG::resize |
( |
size_t |
width, |
|
|
size_t |
height |
|
) |
| |
Resizes the image to the given coordinates.
Attempts to preserve existing pixel data in the image when doing so, but will crop if necessary. No pixel interpolation is done.
- Parameters
-
width | New width of the image. |
height | New height of the image. |
The documentation for this class was generated from the following files: