Main Page | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members

ARLib::Graphics::ARImage Class Reference

Provides functionality for manipulating an image in memory. More...

#include <arimage.h>

List of all members.

Public Member Functions

void CopyTo (ARImage &image)
 Copies the contents of the current image to another image.
bool LoadFromFile (const char *filename)
 Loads the specified file.
bool SaveToFile (const char *filename)
 Saves the current image to file.
char * GetFilename ()
 Returns the filename associated with the image.
bool CreateImage (int width, int height)
 Creates a image in memory.
int GetWidth ()
 Returns the width of the image in pixels.
int GetHeight ()
 Returns the height of the image in pixels.
int GetSize ()
 Returns the total size (width * height).
void ClearImage ()
 Clears the current image by setting all red,green,blue and alpha values to 0 (black).
void FlipHorizontal ()
 Turns the image upside down.
void Reset ()
 Resets the image by freeing up any allocated memory used by the image.
ARColourGetBuffer ()
 Retrieves a pointer to the images memory location.
void GetHistogram (int *histogram, int &minlevel, int &maxlevel, Channel channel=ARLib::CHANNEL_ALPHA)
 Creates a histogram for the specified channel.
ARColourGetPixel (int x, int y)
 Returns a pointer to a pixel.
void SetPixel (int x, int y, ARColour value)
 Sets a pixels red, green, blue and alpha values.
void glDraw ()
 Draws the current image within the OpenGL context.
void glDrawAlpha ()
 Draws the current images alpha channel within the OpenGL context.
void glDrawLuminance ()
 Draw the current images luminance within the OpenGL context.
void glDrawHistogram (Channel channel=CHANNEL_ALPHA)
 Draw a histogram for the specified channel within the OpenGL context.
void DrawCross (int x, int y, int size, const ARColour &colour)
 Draws a cross centred at the passed x and y coordinate.
void DrawBox (int x1, int y1, int x2, int y2, const ARColour &colour)
 Draws a box.
void DrawBox (const Utility::ARRecti &rect, const ARColour &colour)
 Draws a box.
void DrawSolidBox (int x1, int y1, int x2, int y2, const ARColour &colour)
 Draws a solid (filled) box.
void DrawSolidBox (const Utility::ARRecti &rect, const ARColour &colour)
 Draws a solid (filled) box.
void DrawLine (int x1, int y1, int x2, int y2, const ARColour &colour)
 Draws a line.
void DrawNumber (int number, int x, int y, const ARColour &colour)
 Draws an integer value starting at the passed x and y coordinates.
void DrawBuffer (char buffer[], int size, int x, int y, const ARColour &colour)
 Draw a character buffer starting at the passed x and y coordinates.


Detailed Description

Provides functionality for manipulating an image in memory.

Each pixel of the image consists of a red, green, blue and alpha channel and can be manipulated through the ARColour structure.

The current version of the Image class supports the loading and saving of TIFF images through the use of libTIFF.

There are various helper functions for drawing directly onto the image (DrawBox, DrawCross, Draw Line etc).

There are helper functions for drawing within an OpenGL context (glDraw, glDrawAlpha, glDrawLuminance etc).


Member Function Documentation

void ARImage::CopyTo ARImage image  ) 
 

Copies the contents of the current image to another image.

Parameters:
image The target image to copy to.

bool ARImage::CreateImage int  width,
int  height
 

Creates a image in memory.

Parameters:
width The width of the image in pixels.
height The height of the image in pixels.
Returns:
True if the image was successfully created otherwise False is returned.

void ARLib::Graphics::ARImage::DrawBox const Utility::ARRecti rect,
const ARColour colour
 

Draws a box.

Parameters:
rect The box coordinates.
colour The colour of the box.

void ARImage::DrawBox int  x1,
int  y1,
int  x2,
int  y2,
const ARColour colour
 

Draws a box.

Parameters:
x1 The x coordinate of the left side of the box.
y1 The y coordinate of the top of the box.
x2 The x coordinate of the right side of the box.
y2 The y coordinate of the bottom of the box.
colour The colour of the box.

void ARImage::DrawBuffer char  buffer[],
int  size,
int  x,
int  y,
const ARColour colour
 

Draw a character buffer starting at the passed x and y coordinates.

Parameters:
buffer The buffer to draw.
size The size of the buffer.
x The x coordinate of the start of the text.
y The y coordinate of the start of the text.
colour The colour of the text.

void ARImage::DrawCross int  x,
int  y,
int  size,
const ARColour colour
 

Draws a cross centred at the passed x and y coordinate.

Parameters:
x The x coordinate (column) of the centre of the cross.
y The y coordinate (row) of the centre of the cross.
size The size in pixels of the four points of the cross.
colour The colour of the cross.

void ARImage::DrawLine int  x1,
int  y1,
int  x2,
int  y2,
const ARColour colour
 

Draws a line.

Parameters:
x1 The x coordinate of the start of the line.
y1 The y coordinate of the start of the line.
x2 The x coordinate of the end of the line.
y2 The y coordinate of the end of the line.
colour The colour of the line.

void ARImage::DrawNumber int  number,
int  x,
int  y,
const ARColour colour
 

Draws an integer value starting at the passed x and y coordinates.

Parameters:
number The number to draw.
x The x coordinate of the start of the text.
y The y coordinate of the start of the text.
colour The colour of the text.

void ARLib::Graphics::ARImage::DrawSolidBox const Utility::ARRecti rect,
const ARColour colour
 

Draws a solid (filled) box.

Parameters:
rect The box coordinates.
colour The colour of the box.

void ARImage::DrawSolidBox int  x1,
int  y1,
int  x2,
int  y2,
const ARColour colour
 

Draws a solid (filled) box.

Parameters:
x1 The x coordinate of the left side of the box.
y1 The y coordinate of the top of the box.
x2 The x coordinate of the right side of the box.
y2 The y coordinate of the bottom of the box.
colour The colour of the filled box.

ARColour* ARLib::Graphics::ARImage::GetBuffer  )  [inline]
 

Retrieves a pointer to the images memory location.

The method returns a pointer to the first pixel memory location of the image.

The returned buffer can be used for direct manipulation of the underlying image pixels.

Each memory location is a ARColour datatype.

Returns:
An ARColour pointer to the first pixel (bottom left of the image).

char* ARLib::Graphics::ARImage::GetFilename  )  [inline]
 

Returns the filename associated with the image.

Returns:
Returns the filename used by the LoadFromFile function. If the image was never loaded from a file then NULL is returned.

void ARImage::GetHistogram int *  histogram,
int &  minlevel,
int &  maxlevel,
Channel  channel = ARLib::CHANNEL_ALPHA
 

Creates a histogram for the specified channel.

Example Code

Image   img;
int     histogram[256];
int     minlevel, maxlevel;

if (img.LoadFromFile( "sample.tiff" ))
{
        GetHistogram( histogram, minlevel, maxlevel, COLOR_RED );
}

Parameters:
histogram A pointer to an array of 256 int values. The histogram will be loaded into this array.
minlevel This parameter will contain the minimum index in the histogram array that contains a value.
maxlevel This parameter will contain the maximum indxx in the histogram array that contains a value.
channel The image channel to build the histogram for.

ARColour* ARLib::Graphics::ARImage::GetPixel int  x,
int  y
[inline]
 

Returns a pointer to a pixel.

For performance reasons, this method does not check the validity of the passed x and y coordinates.

Parameters:
x An integer in the range 0 >= x < GetWidth().
y An integer in the range 0 >= y < GetHeight().
Returns:
A pointer to an ARColour datatype. The pixels red, green, blue and alpha channels can be manipulated via the ARColour methods and properties.

int ARLib::Graphics::ARImage::GetSize  )  [inline]
 

Returns the total size (width * height).

Returns:
The total number of pixels in the image

void ARLib::Graphics::ARImage::glDrawHistogram Channel  channel = CHANNEL_ALPHA  ) 
 

Draw a histogram for the specified channel within the OpenGL context.

Parameters:
channel Denote which channel should be used.

bool ARImage::LoadFromFile const char *  filename  ) 
 

Loads the specified file.

Currently, only TIFF files are supported.

Parameters:
filename Path of file to load.
Returns:
True if successfully loaded otherwise false.

void ARImage::Reset  ) 
 

Resets the image by freeing up any allocated memory used by the image.

Calling this method will removed all allocated memory for the image.

The width and height of the image are set to zero.

To re-use the image instance, a call the CreateImage or LoadFromFile must be made.

bool ARImage::SaveToFile const char *  filename  ) 
 

Saves the current image to file.

Currently, only TIFF files are supported.

Parameters:
filename Path of file to save.
Returns:
True if successfully saved otherwise false.

void ARLib::Graphics::ARImage::SetPixel int  x,
int  y,
ARColour  value
[inline]
 

Sets a pixels red, green, blue and alpha values.

For performance reasons, this method does not check the validity of the passed x and y coordinates.

Parameters:
x An integer in the range 0 >= x < GetWidth().
y An integer in the range 0 >= y < GetHeight().
value An ARColour value to assign to the pixel.


The documentation for this class was generated from the following files:
Generated on Wed Aug 31 18:01:39 2005 for ARLib by  doxygen 1.3.9.1