GClasses

GClasses::GImage Class Reference

Represents an image. More...

#include <GImage.h>

List of all members.

Public Member Functions

 GImage ()
virtual ~GImage ()
void loadByExtension (const char *szFilename)
 Load a file (Determines the format from the extension. Doesn't handle incorrect extensions. Currently supports .png, .bmp, .ppm, and .pgm.)
void loadPng (const unsigned char *pRawData, size_t nBytes)
 Load the image from a PNG as raw data.
void loadPng (const char *szFilename)
 Load the image from a PNG file.
void loadPngFromHex (const char *szHex)
 Load the image from a hex'd PNG file.
void loadBmp (const char *szFilename)
 Load the image from a BMP file.
void loadBmp (FILE *pFile)
 Load the image from a BMP stream.
void loadBmp (const unsigned char *pRawData, int nLen)
 Load the image from a BMP raw data.
void loadPpm (const char *szFilename)
 Save the image from a PPM file.
void loadPgm (const char *szFilename)
 Load the image from a PGM file.
void saveByExtension (const char *szFilename)
 Saves to a file. (Determines the file type from the extension. Currently supports .png, .bmp, .ppm, and .pgm.)
void savePng (FILE *pFile)
 Save the image as a PNG to a stream.
void savePng (const char *szFilename)
 Save the image as a PNG to a file.
void saveBmp (const char *szFilename)
 Save the image to a BMP file.
void savePpm (const char *szFilename)
 Save the image to a PPM file.
void savePgm (const char *szFilename)
 Save the image to a PGM file.
unsigned int pixel (int nX, int nY) const
 Get a pixel.
unsigned int * pixelRef (int nX, int nY)
 Get a pixel reference.
unsigned int * pixels ()
 Returns the raw array of pixels that represent this image.
unsigned int pixelNearest (int nX, int nY) const
 Returns the color of the pixel nearest to the specified coordinates.
void setPixel (int nX, int nY, unsigned int color)
 Drawing Primitives.
void setPixelIfInRange (int nX, int nY, unsigned int color)
 Set a pixel (may be out of range of the image)
void setPixelTranslucent (int nX, int nY, unsigned int color, double dOpacity)
 Draw a translucent pixel.
unsigned int interpolatePixel (float dX, float dY)
 Returns an interpolated pixel.
void clear (unsigned int color)
 Fill the entire image with a single color.
void setSize (unsigned int nWidth, unsigned int nHeight)
 Erase the image and resize it.
void line (int nX1, int nY1, int nX2, int nY2, unsigned int color)
 Draw a line (may include parts outside the bounds of the image)
void lineNoChecks (int nX1, int nY1, int nX2, int nY2, unsigned int color)
 Draw a line. Don't check to make sure the end-points are within range.
void lineAntiAlias (int nX1, int nY1, int nX2, int nY2, unsigned int color)
 Draw an anti-aliassed line.
void box (int nX1, int nY1, int nX2, int nY2, unsigned int color)
 Draw a hollow box.
void boxFill (int x, int y, int w, int h, unsigned int c)
 Draws a filled-in box.
void circle (int nX, int nY, float dRadius, unsigned int color)
 Draw a circle (uses SafeSetPixel, so it's okay to draw off the edge.
void circleFill (int nX, int nY, float fRadius, unsigned int color)
 Draws a filled-in circle (uses SafeDrawLine, so it's okay to draw off the edge.
void arrow (int x1, int y1, int x2, int y2, unsigned int col, int headSize)
 Draws a simple arrow from (x1, y1) to (x2, y2). headSize is the length (in pixels) of the arrow head. This method is intentionally simple, not exhaustive. If you want a special super-parameterized arrow, you can draw it with combinations of other methods.
void ellipse (int nX, int nY, double dRadius, double dHeightToWidthRatio, unsigned int color)
 Draw an ellipse.
void floodFill (int nX, int nY, unsigned int color, int nTolerance)
 Tolerant flood fill.
void boundaryFill (int nX, int nY, unsigned char nBoundaryR, unsigned char nBoundaryG, unsigned char nBoundaryB, unsigned char nFillR, unsigned char nFillG, unsigned char nFillB, int nTolerance)
 Tolerant boundary fill.
void triangleFill (float x1, float y1, float x2, float y2, float x3, float y3, unsigned int c)
 Draws a filled-in triangle.
void fatLine (float x1, float y1, float x2, float y2, float fThickness, unsigned int c)
 Draws a fat line.
void textChar (char ch, int x, int y, int wid, int hgt, float size, unsigned int col)
 Draws a single text character using a built-in font. (The pixel-height of the font is 12*size.)
void text (const char *text, int x, int y, float size, unsigned int col, int wid=50000, int hgt=50000)
 Prints a line of text using a built-in font. (The pixel-height of the font is 12*size.) col specifies the color.
void dot (float x, float y, float radius, unsigned int fore, unsigned int back)
 Draws a dot at a sub-pixel location.
void flipHorizontally ()
 Flip the image horizontally.
void flipVertically ()
 Flip the image vertically.
void rotate (GImage *pSourceImage, int nX, int nY, double dAngle)
 Rotate the image around the specified point. dAngle is specified in radians. The results are placed in this image. (This image is resized to the same size as the source image, and anything that rotates out of bounds is clipped.)
void rotateCounterClockwise90 (GImage *pSourceImage)
 Makes this a copy of pSourceImage rotated counter-clockwise by 90 degrees.
void rotateClockwise90 (GImage *pSourceImage)
 Makes this a copy of pSourceImage rotated clockwise by 90 degrees.
void scale (unsigned int nNewWidth, unsigned int nNewHeight)
 Scale the image.
void crop (int left, int top, int width, int height)
 Crops the image. (You can crop bigger by using values outside the picture)
void convertToGrayScale ()
 Converts the image to gray scale.
void equalizeColorSpread ()
 Equalizes the color histogram.
void locallyEqualizeColorSpread (int nLocalSize, float fExtent=1)
 Locally equalize the color histogram.
void blur (double dRadius)
 Blur the image by convolving with a Gaussian kernel.
void blurQuick (int iters, int nRadius)
 Blurs by averaging uniformly over a square, plus some optimizations.
void sharpen (double dFactor)
 Sharpen the image.
void invert ()
 Inverts the pixels in the image.
void invertRect (GRect *pRect)
 Inverts the pixels in a particular rect.
void makeEdgesGlow (float fThresh, int nThickness, int nOpacity, unsigned int color)
 Finds edges and makes them glow.
void addBorder (const GImage *pSourceImage, unsigned int cBackground, unsigned int cBorder)
 Draws a border around anything that touches the background color.
void convolve (GImage *pKernel)
void convolveKernel (GImage *pKernel)
void horizDifferenceize ()
void horizSummize ()
void swapData (GImage *pSwapImage)
void copy (GImage *pSourceImage)
void copyRect (GImage *pSourceImage, int nLeft, int nTop, int nRight, int nBottom)
unsigned int width () const
 Returns the width of the image in pixels.
unsigned int height () const
 Returns the height of the image in pixels.
void blit (int x, int y, GImage *pSource, GRect *pSourceRect=NULL)
 Blit an image into this image. The dest area can be out of the dest image. The alpha channel is ignored.
void blitAlpha (int x, int y, GImage *pSource, GRect *pSourceRect=NULL)
 Blit an image into this image. The source rect must be within the source image. The dest area can be out of the dest image. Also performs alpha blending.
void blitAlphaStretch (GRect *pDestRect, GImage *pImage, GRect *pSourceRect=NULL)
 Stretches the specified portion of the source rect to fit the destination rect and alpha-blits onto the this image.
void blitStretchInterpolate (GDoubleRect *pDestRect, GImage *pImage, GDoubleRect *pSourceRect=NULL)
 Performs an interpolating stretch-blit, both to and from a sub-pixel-specified rect.
GImagemunge (int nStyle, float fExtent)
 Munges the image. nStyle should be 0, 1, 2, or 3. Each value munges a different way. fExtent should be between 0 and 1, where 0 doesn't change much and 1 totally munges it. You're responsible to delete the munged image this returns.
void moveLight (double dRadians, float fAmount)
 dRadians ranges from 0 to 2PI fAmount ranges from 0 to about 4, but small values (like .1) seem to look best
void stretch (int nXStart, int nYStart, int nXEnd, int nYEnd)
 This uses a Gaussian to interpolate between the original image and a translated image. The result appears as though the start point were stretched to the end point.
void captcha (const char *szText, GRand *pRand)
 Make a string of text that would be difficult for non-humans to read.
void gaussianKernel (int nWidth, float fDepth)
 Generates a discrete kernel to approximate a Gaussian. nWidth is both the width and height of the kernel. (Usually an odd number is desireable so there is a bright center pixel.) fDepth is the value of the center of the kernel. 1 <= fDepth <= 255. The values are computed such that the center of each edge has a value of 1.
void highPassFilter (double dExtent)
 Values for dExtent range from 0 to 1. In most cases, a small value (like .1) is desireable.
void lowPassFilter (double dExtent)
 Values for dExtent range from 0 to 1. In most cases, a small value (like .1) is desireable.
void threshold (int nGrayscaleValue)
 Thresholds the image (to black and white) at the specified grayscale value. (0 <= nGrayscaleValue < 65281). (65281 = 255 * 256 + 1)
void medianFilter (float fRadius)
 Sets every pixel to the grayscale median of the neighborhood that fits within the specified radius. (A radius of 1 will include only 4 neighbors. A radius of 1.5 will include 8 neighbors.)
void dialate (GImage *pStructuringElement)
 a basic morphological operator
void erode (GImage *pStructuringElement)
 A basic morphological operator.
void open (int nPixels)
 if nPixels > 0, opens the image by the specified number of pixels if nPixels < 0, closes the image by the specified number of pixels
void setGlobalAlpha (int alpha)
 Sets the alpha channel value for all pixels in the image.
double moment (double centerX, double centerY, double i, double j)
void meanAndOrientation (double *pMeanX, double *pMeanY, double *pRadians)
 Uses moments to compute mean and orientation.
void gradientMagnitudeImage (const GImage *pIn)
unsigned int interpolateWithinTriangle (float w0, float w1, float w2, float x0, float y0, float x1, float y1, float x2, float y2)
 Given three weights and three points, interpolate the point, and interpolate the color at that point.
void contrastAndBrightness (float fContrastScale, int nBrightnessDelta)
 The value of each channel is centered around 128, multiplied by fContrastScale, added to nBrightnessDelta, and clipped to [0-255].
void hueSaturationAndValue (GImage *pSource, float hue, float saturation, float value)
 Adjusts the hue, saturation, and value of the image by the specified amounts. The saturation and value are clipped with a min of 0 and a max of 1. The hue has a cycle of 1, so adjusting by any integer will leave the hue unchanged.
void shade (float fStart, float fEnd, float fSteepness)
 Makes the darkest parts of the image darker. (Note that if you invert first, shade, and then invert again, you will have hilighted the lightest parts of the image.) fStart is ranges from 0 to 1, and specifies the brightness threshold at which the shading begins. fEnd also ranges from 0 to 1. Everything darker than fEnd will be completely black. fStart must be >= fEnd. fSteepness specifies the curvature of the gradient.
void convertAbgrToArgb ()
 Converts the whole image from Abgr (little-endian Rgba) to big-endian Argb.
void replaceColor (unsigned int before, unsigned int after)
 Replaces every occurrence of the exact color "before" with "after".

Static Public Member Functions

static int measureCharWidth (char c, float size)
 Determines how many pixels of width are required to print a single character of text.
static int measureTextWidth (const char *text, float size)
 Determines how many pixels of width are required to print a line of text.
static int countTextChars (int horizArea, const char *text, float size)
 Counts the number of characters that can be printed in the given horizArea.
static bool isPointInsideTriangle (float x, float y, float x0, float y0, float x1, float y1, float x2, float y2)
 Determines whether the point (x, y) is inside the triangle specified by (x0, y0), (x1, y1), (x2, y2). On any edge is considered to be within the triangle.
static void triangleWeights (float *pW0, float *pW1, float *pW2, float x, float y, float x0, float y0, float x1, float y1, float x2, float y2)
 Given the three vertices of a triangle, this computes the weights for each vertex that linearly interpolates to the point (x, y)

Protected Member Functions

void loadPixMap (FILE *pFile, bool bTextData, bool bGrayScale)
void savePixMap (FILE *pFile, bool bTextData, bool bGrayScale)
void floodFillRecurser (int nX, int nY, unsigned char nSrcR, unsigned char nSrcG, unsigned char nSrcB, unsigned char nDstR, unsigned char nDstG, unsigned char nDstB, int nTolerance)
bool clipLineEndPoints (int &nX1, int &nY1, int &nX2, int &nY2)
void textCharSmall (char ch, int x, int y, int wid, int hgt, float size, unsigned int col)

Protected Attributes

unsigned int * m_pPixels
unsigned int m_width
unsigned int m_height

Detailed Description

Represents an image.


Constructor & Destructor Documentation

GClasses::GImage::GImage ( )
virtual GClasses::GImage::~GImage ( ) [virtual]

Member Function Documentation

void GClasses::GImage::addBorder ( const GImage pSourceImage,
unsigned int  cBackground,
unsigned int  cBorder 
)

Draws a border around anything that touches the background color.

void GClasses::GImage::arrow ( int  x1,
int  y1,
int  x2,
int  y2,
unsigned int  col,
int  headSize 
)

Draws a simple arrow from (x1, y1) to (x2, y2). headSize is the length (in pixels) of the arrow head. This method is intentionally simple, not exhaustive. If you want a special super-parameterized arrow, you can draw it with combinations of other methods.

void GClasses::GImage::blit ( int  x,
int  y,
GImage pSource,
GRect pSourceRect = NULL 
)

Blit an image into this image. The dest area can be out of the dest image. The alpha channel is ignored.

void GClasses::GImage::blitAlpha ( int  x,
int  y,
GImage pSource,
GRect pSourceRect = NULL 
)

Blit an image into this image. The source rect must be within the source image. The dest area can be out of the dest image. Also performs alpha blending.

void GClasses::GImage::blitAlphaStretch ( GRect pDestRect,
GImage pImage,
GRect pSourceRect = NULL 
)

Stretches the specified portion of the source rect to fit the destination rect and alpha-blits onto the this image.

void GClasses::GImage::blitStretchInterpolate ( GDoubleRect pDestRect,
GImage pImage,
GDoubleRect pSourceRect = NULL 
)

Performs an interpolating stretch-blit, both to and from a sub-pixel-specified rect.

void GClasses::GImage::blur ( double  dRadius)

Blur the image by convolving with a Gaussian kernel.

void GClasses::GImage::blurQuick ( int  iters,
int  nRadius 
)

Blurs by averaging uniformly over a square, plus some optimizations.

void GClasses::GImage::boundaryFill ( int  nX,
int  nY,
unsigned char  nBoundaryR,
unsigned char  nBoundaryG,
unsigned char  nBoundaryB,
unsigned char  nFillR,
unsigned char  nFillG,
unsigned char  nFillB,
int  nTolerance 
)

Tolerant boundary fill.

void GClasses::GImage::box ( int  nX1,
int  nY1,
int  nX2,
int  nY2,
unsigned int  color 
)

Draw a hollow box.

void GClasses::GImage::boxFill ( int  x,
int  y,
int  w,
int  h,
unsigned int  c 
)

Draws a filled-in box.

void GClasses::GImage::captcha ( const char *  szText,
GRand pRand 
)

Make a string of text that would be difficult for non-humans to read.

void GClasses::GImage::circle ( int  nX,
int  nY,
float  dRadius,
unsigned int  color 
)

Draw a circle (uses SafeSetPixel, so it's okay to draw off the edge.

void GClasses::GImage::circleFill ( int  nX,
int  nY,
float  fRadius,
unsigned int  color 
)

Draws a filled-in circle (uses SafeDrawLine, so it's okay to draw off the edge.

void GClasses::GImage::clear ( unsigned int  color)

Fill the entire image with a single color.

bool GClasses::GImage::clipLineEndPoints ( int &  nX1,
int &  nY1,
int &  nX2,
int &  nY2 
) [protected]
void GClasses::GImage::contrastAndBrightness ( float  fContrastScale,
int  nBrightnessDelta 
)

The value of each channel is centered around 128, multiplied by fContrastScale, added to nBrightnessDelta, and clipped to [0-255].

void GClasses::GImage::convertAbgrToArgb ( )

Converts the whole image from Abgr (little-endian Rgba) to big-endian Argb.

void GClasses::GImage::convertToGrayScale ( )

Converts the image to gray scale.

void GClasses::GImage::convolve ( GImage pKernel)
void GClasses::GImage::convolveKernel ( GImage pKernel)
void GClasses::GImage::copy ( GImage pSourceImage)
void GClasses::GImage::copyRect ( GImage pSourceImage,
int  nLeft,
int  nTop,
int  nRight,
int  nBottom 
)
static int GClasses::GImage::countTextChars ( int  horizArea,
const char *  text,
float  size 
) [static]

Counts the number of characters that can be printed in the given horizArea.

void GClasses::GImage::crop ( int  left,
int  top,
int  width,
int  height 
)

Crops the image. (You can crop bigger by using values outside the picture)

void GClasses::GImage::dialate ( GImage pStructuringElement)

a basic morphological operator

void GClasses::GImage::dot ( float  x,
float  y,
float  radius,
unsigned int  fore,
unsigned int  back 
)

Draws a dot at a sub-pixel location.

void GClasses::GImage::ellipse ( int  nX,
int  nY,
double  dRadius,
double  dHeightToWidthRatio,
unsigned int  color 
)

Draw an ellipse.

void GClasses::GImage::equalizeColorSpread ( )

Equalizes the color histogram.

void GClasses::GImage::erode ( GImage pStructuringElement)

A basic morphological operator.

void GClasses::GImage::fatLine ( float  x1,
float  y1,
float  x2,
float  y2,
float  fThickness,
unsigned int  c 
)

Draws a fat line.

void GClasses::GImage::flipHorizontally ( )

Flip the image horizontally.

void GClasses::GImage::flipVertically ( )

Flip the image vertically.

void GClasses::GImage::floodFill ( int  nX,
int  nY,
unsigned int  color,
int  nTolerance 
)

Tolerant flood fill.

void GClasses::GImage::floodFillRecurser ( int  nX,
int  nY,
unsigned char  nSrcR,
unsigned char  nSrcG,
unsigned char  nSrcB,
unsigned char  nDstR,
unsigned char  nDstG,
unsigned char  nDstB,
int  nTolerance 
) [protected]
void GClasses::GImage::gaussianKernel ( int  nWidth,
float  fDepth 
)

Generates a discrete kernel to approximate a Gaussian. nWidth is both the width and height of the kernel. (Usually an odd number is desireable so there is a bright center pixel.) fDepth is the value of the center of the kernel. 1 <= fDepth <= 255. The values are computed such that the center of each edge has a value of 1.

void GClasses::GImage::gradientMagnitudeImage ( const GImage pIn)
unsigned int GClasses::GImage::height ( ) const [inline]

Returns the height of the image in pixels.

void GClasses::GImage::highPassFilter ( double  dExtent)

Values for dExtent range from 0 to 1. In most cases, a small value (like .1) is desireable.

void GClasses::GImage::horizDifferenceize ( )
void GClasses::GImage::horizSummize ( )
void GClasses::GImage::hueSaturationAndValue ( GImage pSource,
float  hue,
float  saturation,
float  value 
)

Adjusts the hue, saturation, and value of the image by the specified amounts. The saturation and value are clipped with a min of 0 and a max of 1. The hue has a cycle of 1, so adjusting by any integer will leave the hue unchanged.

unsigned int GClasses::GImage::interpolatePixel ( float  dX,
float  dY 
)

Returns an interpolated pixel.

unsigned int GClasses::GImage::interpolateWithinTriangle ( float  w0,
float  w1,
float  w2,
float  x0,
float  y0,
float  x1,
float  y1,
float  x2,
float  y2 
)

Given three weights and three points, interpolate the point, and interpolate the color at that point.

void GClasses::GImage::invert ( )

Inverts the pixels in the image.

void GClasses::GImage::invertRect ( GRect pRect)

Inverts the pixels in a particular rect.

static bool GClasses::GImage::isPointInsideTriangle ( float  x,
float  y,
float  x0,
float  y0,
float  x1,
float  y1,
float  x2,
float  y2 
) [static]

Determines whether the point (x, y) is inside the triangle specified by (x0, y0), (x1, y1), (x2, y2). On any edge is considered to be within the triangle.

void GClasses::GImage::line ( int  nX1,
int  nY1,
int  nX2,
int  nY2,
unsigned int  color 
)

Draw a line (may include parts outside the bounds of the image)

void GClasses::GImage::lineAntiAlias ( int  nX1,
int  nY1,
int  nX2,
int  nY2,
unsigned int  color 
)

Draw an anti-aliassed line.

void GClasses::GImage::lineNoChecks ( int  nX1,
int  nY1,
int  nX2,
int  nY2,
unsigned int  color 
)

Draw a line. Don't check to make sure the end-points are within range.

void GClasses::GImage::loadBmp ( const char *  szFilename)

Load the image from a BMP file.

void GClasses::GImage::loadBmp ( FILE *  pFile)

Load the image from a BMP stream.

void GClasses::GImage::loadBmp ( const unsigned char *  pRawData,
int  nLen 
)

Load the image from a BMP raw data.

void GClasses::GImage::loadByExtension ( const char *  szFilename)

Load a file (Determines the format from the extension. Doesn't handle incorrect extensions. Currently supports .png, .bmp, .ppm, and .pgm.)

void GClasses::GImage::loadPgm ( const char *  szFilename)

Load the image from a PGM file.

void GClasses::GImage::loadPixMap ( FILE *  pFile,
bool  bTextData,
bool  bGrayScale 
) [protected]
void GClasses::GImage::loadPng ( const unsigned char *  pRawData,
size_t  nBytes 
)

Load the image from a PNG as raw data.

void GClasses::GImage::loadPng ( const char *  szFilename)

Load the image from a PNG file.

void GClasses::GImage::loadPngFromHex ( const char *  szHex)

Load the image from a hex'd PNG file.

void GClasses::GImage::loadPpm ( const char *  szFilename)

Save the image from a PPM file.

void GClasses::GImage::locallyEqualizeColorSpread ( int  nLocalSize,
float  fExtent = 1 
)

Locally equalize the color histogram.

void GClasses::GImage::lowPassFilter ( double  dExtent)

Values for dExtent range from 0 to 1. In most cases, a small value (like .1) is desireable.

void GClasses::GImage::makeEdgesGlow ( float  fThresh,
int  nThickness,
int  nOpacity,
unsigned int  color 
)

Finds edges and makes them glow.

void GClasses::GImage::meanAndOrientation ( double *  pMeanX,
double *  pMeanY,
double *  pRadians 
)

Uses moments to compute mean and orientation.

static int GClasses::GImage::measureCharWidth ( char  c,
float  size 
) [static]

Determines how many pixels of width are required to print a single character of text.

static int GClasses::GImage::measureTextWidth ( const char *  text,
float  size 
) [static]

Determines how many pixels of width are required to print a line of text.

void GClasses::GImage::medianFilter ( float  fRadius)

Sets every pixel to the grayscale median of the neighborhood that fits within the specified radius. (A radius of 1 will include only 4 neighbors. A radius of 1.5 will include 8 neighbors.)

double GClasses::GImage::moment ( double  centerX,
double  centerY,
double  i,
double  j 
)
void GClasses::GImage::moveLight ( double  dRadians,
float  fAmount 
)

dRadians ranges from 0 to 2PI fAmount ranges from 0 to about 4, but small values (like .1) seem to look best

GImage* GClasses::GImage::munge ( int  nStyle,
float  fExtent 
)

Munges the image. nStyle should be 0, 1, 2, or 3. Each value munges a different way. fExtent should be between 0 and 1, where 0 doesn't change much and 1 totally munges it. You're responsible to delete the munged image this returns.

void GClasses::GImage::open ( int  nPixels)

if nPixels > 0, opens the image by the specified number of pixels if nPixels < 0, closes the image by the specified number of pixels

unsigned int GClasses::GImage::pixel ( int  nX,
int  nY 
) const [inline]

Get a pixel.

unsigned int GClasses::GImage::pixelNearest ( int  nX,
int  nY 
) const

Returns the color of the pixel nearest to the specified coordinates.

unsigned int* GClasses::GImage::pixelRef ( int  nX,
int  nY 
) [inline]

Get a pixel reference.

unsigned int* GClasses::GImage::pixels ( ) [inline]

Returns the raw array of pixels that represent this image.

void GClasses::GImage::replaceColor ( unsigned int  before,
unsigned int  after 
)

Replaces every occurrence of the exact color "before" with "after".

void GClasses::GImage::rotate ( GImage pSourceImage,
int  nX,
int  nY,
double  dAngle 
)

Rotate the image around the specified point. dAngle is specified in radians. The results are placed in this image. (This image is resized to the same size as the source image, and anything that rotates out of bounds is clipped.)

void GClasses::GImage::rotateClockwise90 ( GImage pSourceImage)

Makes this a copy of pSourceImage rotated clockwise by 90 degrees.

void GClasses::GImage::rotateCounterClockwise90 ( GImage pSourceImage)

Makes this a copy of pSourceImage rotated counter-clockwise by 90 degrees.

void GClasses::GImage::saveBmp ( const char *  szFilename)

Save the image to a BMP file.

void GClasses::GImage::saveByExtension ( const char *  szFilename)

Saves to a file. (Determines the file type from the extension. Currently supports .png, .bmp, .ppm, and .pgm.)

void GClasses::GImage::savePgm ( const char *  szFilename)

Save the image to a PGM file.

void GClasses::GImage::savePixMap ( FILE *  pFile,
bool  bTextData,
bool  bGrayScale 
) [protected]
void GClasses::GImage::savePng ( FILE *  pFile)

Save the image as a PNG to a stream.

void GClasses::GImage::savePng ( const char *  szFilename)

Save the image as a PNG to a file.

void GClasses::GImage::savePpm ( const char *  szFilename)

Save the image to a PPM file.

void GClasses::GImage::scale ( unsigned int  nNewWidth,
unsigned int  nNewHeight 
)

Scale the image.

void GClasses::GImage::setGlobalAlpha ( int  alpha)

Sets the alpha channel value for all pixels in the image.

void GClasses::GImage::setPixel ( int  nX,
int  nY,
unsigned int  color 
) [inline]

Drawing Primitives.

void GClasses::GImage::setPixelIfInRange ( int  nX,
int  nY,
unsigned int  color 
)

Set a pixel (may be out of range of the image)

void GClasses::GImage::setPixelTranslucent ( int  nX,
int  nY,
unsigned int  color,
double  dOpacity 
)

Draw a translucent pixel.

void GClasses::GImage::setSize ( unsigned int  nWidth,
unsigned int  nHeight 
)

Erase the image and resize it.

void GClasses::GImage::shade ( float  fStart,
float  fEnd,
float  fSteepness 
)

Makes the darkest parts of the image darker. (Note that if you invert first, shade, and then invert again, you will have hilighted the lightest parts of the image.) fStart is ranges from 0 to 1, and specifies the brightness threshold at which the shading begins. fEnd also ranges from 0 to 1. Everything darker than fEnd will be completely black. fStart must be >= fEnd. fSteepness specifies the curvature of the gradient.

void GClasses::GImage::sharpen ( double  dFactor)

Sharpen the image.

void GClasses::GImage::stretch ( int  nXStart,
int  nYStart,
int  nXEnd,
int  nYEnd 
)

This uses a Gaussian to interpolate between the original image and a translated image. The result appears as though the start point were stretched to the end point.

void GClasses::GImage::swapData ( GImage pSwapImage)
void GClasses::GImage::text ( const char *  text,
int  x,
int  y,
float  size,
unsigned int  col,
int  wid = 50000,
int  hgt = 50000 
)

Prints a line of text using a built-in font. (The pixel-height of the font is 12*size.) col specifies the color.

void GClasses::GImage::textChar ( char  ch,
int  x,
int  y,
int  wid,
int  hgt,
float  size,
unsigned int  col 
)

Draws a single text character using a built-in font. (The pixel-height of the font is 12*size.)

void GClasses::GImage::textCharSmall ( char  ch,
int  x,
int  y,
int  wid,
int  hgt,
float  size,
unsigned int  col 
) [protected]
void GClasses::GImage::threshold ( int  nGrayscaleValue)

Thresholds the image (to black and white) at the specified grayscale value. (0 <= nGrayscaleValue < 65281). (65281 = 255 * 256 + 1)

void GClasses::GImage::triangleFill ( float  x1,
float  y1,
float  x2,
float  y2,
float  x3,
float  y3,
unsigned int  c 
)

Draws a filled-in triangle.

static void GClasses::GImage::triangleWeights ( float *  pW0,
float *  pW1,
float *  pW2,
float  x,
float  y,
float  x0,
float  y0,
float  x1,
float  y1,
float  x2,
float  y2 
) [static]

Given the three vertices of a triangle, this computes the weights for each vertex that linearly interpolates to the point (x, y)

unsigned int GClasses::GImage::width ( ) const [inline]

Returns the width of the image in pixels.


Member Data Documentation

unsigned int GClasses::GImage::m_height [protected]
unsigned int* GClasses::GImage::m_pPixels [protected]
unsigned int GClasses::GImage::m_width [protected]