The Conley-Morse Graphs Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PngImage Class Reference

An interface to the PNG library. More...

#include <pngimage.h>

Public Member Functions

 PngImage (int _width, int _height, int _bgcolor=0xFFFFFF)
 The constructor of an empty 24-bit PNG image. More...
 
 PngImage (const char *filename)
 The constructor which reads a PNG image from a file. More...
 
 ~PngImage ()
 The destructor. More...
 
void putPixel (int x, int y, int color=0x000000)
 Plots a pixel in the image with the given RGB color. More...
 
int getPixel (int x, int y) const
 Returns the 0xRRGGBB color value of the given pixel or -1 if the pixel is outside the image. More...
 
int width () const
 Returns the width of the image. More...
 
int height () const
 Returns the height of the image. More...
 
void save (const char *filename) const
 Writes the image to a PNG file. More...
 

Private Member Functions

 PngImage (const PngImage &src)
 The copy constructor is not allowed. More...
 
PngImageoperator= (const PngImage &src)
 The assignment operator is not allowed. More...
 

Private Attributes

int imgWidth
 The width of the image in pixels. More...
 
int imgHeight
 The height of the image in pixels. More...
 
unsigned char * buffer
 The buffer of the picture in RGB byte sequences. More...
 

Detailed Description

An interface to the PNG library.

Supports creating a 24-bit image, writing individual pixels, and saving the image to a PNG file.

Definition at line 51 of file pngimage.h.

Constructor & Destructor Documentation

◆ PngImage() [1/3]

PngImage::PngImage ( int  _width,
int  _height,
int  _bgcolor = 0xFFFFFF 
)
inline

The constructor of an empty 24-bit PNG image.

The default background color is white.

Definition at line 103 of file pngimage.h.

References buffer, imgHeight, and imgWidth.

◆ PngImage() [2/3]

PngImage::PngImage ( const char *  filename)
inline

The constructor which reads a PNG image from a file.

Throws an error text message (const char *) in case of failure.

Definition at line 175 of file pngimage.h.

References buffer, height(), imgHeight, imgWidth, and width().

◆ ~PngImage()

PngImage::~PngImage ( )
inline

The destructor.

Definition at line 127 of file pngimage.h.

References buffer.

◆ PngImage() [3/3]

PngImage::PngImage ( const PngImage src)
inlineprivate

The copy constructor is not allowed.

Definition at line 134 of file pngimage.h.

Member Function Documentation

◆ getPixel()

int PngImage::getPixel ( int  x,
int  y 
) const
inline

Returns the 0xRRGGBB color value of the given pixel or -1 if the pixel is outside the image.

Definition at line 155 of file pngimage.h.

References buffer, imgHeight, and imgWidth.

◆ height()

int PngImage::height ( ) const
inline

Returns the height of the image.

Definition at line 168 of file pngimage.h.

References imgHeight.

Referenced by PngImage().

◆ operator=()

PngImage & PngImage::operator= ( const PngImage src)
inlineprivate

The assignment operator is not allowed.

Definition at line 139 of file pngimage.h.

◆ putPixel()

void PngImage::putPixel ( int  x,
int  y,
int  color = 0x000000 
)
inline

Plots a pixel in the image with the given RGB color.

The color is encoded as 0xRRGGBB. Black by default.

Definition at line 144 of file pngimage.h.

References buffer, imgHeight, and imgWidth.

◆ save()

void PngImage::save ( const char *  filename) const
inline

Writes the image to a PNG file.

Throws an error text message (const char *) in case of failure.

Definition at line 267 of file pngimage.h.

References buffer, imgHeight, and imgWidth.

◆ width()

int PngImage::width ( ) const
inline

Returns the width of the image.

Definition at line 163 of file pngimage.h.

References imgWidth.

Referenced by PngImage().

Member Data Documentation

◆ buffer

unsigned char* PngImage::buffer
private

The buffer of the picture in RGB byte sequences.

Definition at line 97 of file pngimage.h.

Referenced by getPixel(), PngImage(), putPixel(), save(), and ~PngImage().

◆ imgHeight

int PngImage::imgHeight
private

The height of the image in pixels.

Definition at line 94 of file pngimage.h.

Referenced by getPixel(), height(), PngImage(), putPixel(), and save().

◆ imgWidth

int PngImage::imgWidth
private

The width of the image in pixels.

Definition at line 91 of file pngimage.h.

Referenced by getPixel(), PngImage(), putPixel(), save(), and width().


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