GClasses
|
Represents an image.
#include <GImage.h>
Public Member Functions | |
GImage () | |
virtual | ~GImage () |
void | addBorder (const GImage *pSourceImage, unsigned int cBackground, unsigned int cBorder) |
Draws a border around anything that touches the background color. More... | |
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. More... | |
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. The pSourceRect must be within the bounds of the source image. If pSourceRect is NULL, then the full source image is used. More... | |
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. More... | |
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. More... | |
void | blitStretchInterpolate (GDoubleRect *pDestRect, GImage *pImage, GDoubleRect *pSourceRect=NULL) |
Performs an interpolating stretch-blit, both to and from a sub-pixel-specified rect. More... | |
void | blur (double dRadius) |
Blur the image by convolving with a Gaussian kernel. More... | |
void | blurQuick (int iters, int nRadius) |
Blurs by averaging uniformly over a square, plus some optimizations. More... | |
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. More... | |
void | box (int nX1, int nY1, int nX2, int nY2, unsigned int color) |
Draw a hollow box. More... | |
void | boxFill (int x, int y, int w, int h, unsigned int c) |
Draws a filled-in box. More... | |
void | captcha (const char *szText, GRand *pRand) |
Make a string of text that would be difficult for non-humans to read. More... | |
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. More... | |
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. More... | |
void | clear (unsigned int color) |
Fill the entire image with a single color. More... | |
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]. More... | |
void | convertAbgrToArgb () |
Converts the whole image from Abgr (little-endian Rgba) to big-endian Argb. More... | |
void | convertToGrayScale () |
Converts the image to gray scale. More... | |
void | convolve (GImage *pKernel) |
void | convolveKernel (GImage *pKernel) |
void | copy (GImage *pSourceImage) |
void | copyRect (GImage *pSourceImage, int nLeft, int nTop, int nRight, int nBottom) |
void | crop (int left, int top, int width, int height) |
Crops the image. (You can crop bigger by using values outside the picture) More... | |
void | dialate (GImage *pStructuringElement) |
a basic morphological operator More... | |
void | dot (float x, float y, float radius, unsigned int fore, unsigned int back) |
Draws a dot at a sub-pixel location. More... | |
void | ellipse (int nX, int nY, double dRadius, double dHeightToWidthRatio, unsigned int color) |
Draw an ellipse. More... | |
void | equalizeColorSpread () |
Equalizes the color histogram. More... | |
void | erode (GImage *pStructuringElement) |
A basic morphological operator. More... | |
void | fatLine (float x1, float y1, float x2, float y2, float fThickness, unsigned int c) |
Draws a fat line. More... | |
void | flipHorizontally () |
Flip the image horizontally. More... | |
void | flipVertically () |
Flip the image vertically. More... | |
void | floodFill (int nX, int nY, unsigned int color, int nTolerance) |
Tolerant flood fill. More... | |
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. More... | |
void | gradientMagnitudeImage (const GImage *pIn) |
unsigned int | height () const |
Returns the height of the image in pixels. More... | |
void | highPassFilter (double dExtent) |
Values for dExtent range from 0 to 1. In most cases, a small value (like .1) is desireable. More... | |
void | horizDifferenceize () |
void | horizSummize () |
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. More... | |
unsigned int | interpolatePixel (float dX, float dY) |
Returns an interpolated pixel. More... | |
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. More... | |
void | invert () |
Inverts the pixels in the image. More... | |
void | invertRect (GRect *pRect) |
Inverts the pixels in a particular rect. More... | |
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) More... | |
void | lineAntiAlias (int nX1, int nY1, int nX2, int nY2, unsigned int color) |
Draw an anti-aliassed line. More... | |
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. More... | |
void | loadBmp (const char *szFilename) |
Load the image from a BMP file. More... | |
void | loadBmp (FILE *pFile) |
Load the image from a BMP stream. More... | |
void | loadBmp (const unsigned char *pRawData, int nLen) |
Load the image from a BMP raw data. More... | |
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.) More... | |
void | loadPgm (const char *szFilename) |
Load the image from a PGM file. More... | |
void | loadPpm (const char *szFilename) |
Save the image from a PPM file. More... | |
void | locallyEqualizeColorSpread (int nLocalSize, float fExtent=1) |
Locally equalize the color histogram. More... | |
void | lowPassFilter (double dExtent) |
Values for dExtent range from 0 to 1. In most cases, a small value (like .1) is desireable. More... | |
void | makeEdgesGlow (float fThresh, int nThickness, int nOpacity, unsigned int color) |
Finds edges and makes them glow. More... | |
void | meanAndOrientation (double *pMeanX, double *pMeanY, double *pRadians) |
Uses moments to compute mean and orientation. More... | |
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.) More... | |
double | moment (double centerX, double centerY, double i, double j) |
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 More... | |
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. More... | |
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 More... | |
unsigned int | pixel (int nX, int nY) const |
Get a pixel. More... | |
unsigned int | pixelNearest (int nX, int nY) const |
Returns the color of the pixel nearest to the specified coordinates. More... | |
unsigned int * | pixelRef (int nX, int nY) |
Get a pixel reference. More... | |
unsigned int * | pixels () |
Returns the raw array of pixels that represent this image. More... | |
void | replaceColor (unsigned int before, unsigned int after) |
Replaces every occurrence of the exact color "before" with "after". More... | |
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.) More... | |
void | rotateClockwise90 (GImage *pSourceImage) |
Makes this a copy of pSourceImage rotated clockwise by 90 degrees. More... | |
void | rotateCounterClockwise90 (GImage *pSourceImage) |
Makes this a copy of pSourceImage rotated counter-clockwise by 90 degrees. More... | |
void | saveBmp (const char *szFilename) |
Save the image to a BMP file. More... | |
void | saveByExtension (const char *szFilename) |
Saves to a file. (Determines the file type from the extension. Currently supports .png, .bmp, .ppm, and .pgm.) More... | |
void | savePgm (const char *szFilename) |
Save the image to a PGM file. More... | |
void | savePpm (const char *szFilename) |
Save the image to a PPM file. More... | |
void | scale (unsigned int nNewWidth, unsigned int nNewHeight) |
Scale the image. More... | |
void | setGlobalAlpha (int alpha) |
Sets the alpha channel value for all pixels in the image. More... | |
void | setPixel (int nX, int nY, unsigned int color) |
Drawing Primitives. More... | |
void | setPixelIfInRange (int nX, int nY, unsigned int color) |
Set a pixel (may be out of range of the image) More... | |
void | setPixelTranslucent (int nX, int nY, unsigned int color, double dOpacity) |
Draw a translucent pixel. More... | |
void | setSize (unsigned int nWidth, unsigned int nHeight) |
Erase the image and resize it. More... | |
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. More... | |
void | sharpen (double dFactor) |
Sharpen the image. More... | |
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. More... | |
void | swapData (GImage *pSwapImage) |
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. More... | |
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.) More... | |
void | threshold (int nGrayscaleValue) |
Thresholds the image (to black and white) at the specified grayscale value. (0 <= nGrayscaleValue < 65281). (65281 = 255 * 256 + 1) More... | |
void | triangleFill (float x1, float y1, float x2, float y2, float x3, float y3, unsigned int c) |
Draws a filled-in triangle. More... | |
unsigned int | width () const |
Returns the width of the image in pixels. More... | |
Static Public Member Functions | |
static int | countTextChars (int horizArea, const char *text, float size) |
Counts the number of characters that can be printed in the given horizArea. More... | |
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. More... | |
static int | measureCharWidth (char c, float size) |
Determines how many pixels of width are required to print a single character of text. More... | |
static int | measureTextWidth (const char *text, float size) |
Determines how many pixels of width are required to print a line of text. More... | |
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) More... | |
Protected Member Functions | |
bool | clipLineEndPoints (int &nX1, int &nY1, int &nX2, int &nY2) |
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) |
void | loadPixMap (FILE *pFile, bool bTextData, bool bGrayScale) |
void | savePixMap (FILE *pFile, bool bTextData, bool bGrayScale) |
void | textCharSmall (char ch, int x, int y, int wid, int hgt, float size, unsigned int col) |
Protected Attributes | |
unsigned int | m_height |
unsigned int * | m_pPixels |
unsigned int | m_width |
GClasses::GImage::GImage | ( | ) |
|
virtual |
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.
Blit an image into this image. The dest area can be out of the dest image. The alpha channel is ignored. The pSourceRect must be within the bounds of the source image. If pSourceRect is NULL, then the full source image is used.
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.
|
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 |
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.
|
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 | ) |
|
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 |
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.
|
protected |
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 |
Determines how many pixels of width are required to print a single character of text.
|
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
|
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.
|
inline |
Get a pixel reference.
|
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.
|
protected |
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.
|
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.)
|
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 |
Given the three vertices of a triangle, this computes the weights for each vertex that linearly interpolates to the point (x, y)
|
inline |
Returns the width of the image in pixels.
|
protected |
|
protected |
|
protected |