Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

image::image_t Class Reference

A 2D image. More...

#include <image.h>

List of all members.

Public Types

enum  format { GREYSCALE = 1, RGB = 3, RGBA = 4 }
 Format the pixels are stored in. More...

enum  bpc { BYTE = 8, WORD = 32, DWORD = 64 }
 Bits per channel. More...


Public Methods

 image_t (unsigned int width, unsigned int height, format fmat, unsigned int depth)
 Constructor. More...

 image_t (unsigned int width, unsigned int height, format fmat, unsigned int depth, const void *pixels)
 Constructor. More...

 ~image_t (void)
unsigned int get_width (void) const
 Returns the width of the image.

unsigned int get_height (void) const
 Returns the height of the image.

format get_format (void) const
 Returns the format of the image.

unsigned int get_bpc (void) const
 Returns the bits per channel of the image.

const void * get_pixels (void) const
 Returns a read-only pointer to pixel data.

bool seek (unsigned int x, unsigned int y)
 Seeks to the pixel at x, y. More...

bool read (unsigned char &gray)
 Reads the current pixel in the image. More...

bool read (unsigned char &r, unsigned char &g, unsigned char &b)
 Reads the current pixel in the image. More...

bool read (unsigned char &r, unsigned char &g, unsigned char &b, unsigned char &a)
 Reads the current pixel in the image. More...

bool write (unsigned char gray)
 Sets the current pixel in the image. More...

bool write (unsigned char r, unsigned char g, unsigned char b)
 Sets the current pixel in the image. More...

bool write (unsigned char r, unsigned char g, unsigned char b, unsigned char a)
 Sets the current pixel in the image. More...

bool get_pixel (unsigned char &r, unsigned char &g, unsigned char &b, unsigned int x, unsigned int y) const
 Gets the pixel at x, y. More...

bool get_pixel (unsigned char &r, unsigned char &g, unsigned char &b, unsigned char &a, unsigned int x, unsigned int y) const
 Gets the pixel at x, y. More...

bool set_pixel (unsigned char r, unsigned char g, unsigned char b, unsigned int x, unsigned int y)
 Sets the pixel at x, y. More...

bool set_pixel (unsigned char r, unsigned char g, unsigned char b, unsigned char a, unsigned int x, unsigned int y)
 Sets the pixel at x, y. More...

bool blend_pixel (unsigned char r, unsigned char g, unsigned char b, unsigned char a, unsigned int x, unsigned int y)
 Alpha blends the color r, g, b, a to the pixel x, y.

void flip_horizontal (void)
 Flips the image across the horizontal axis.

bool blit (const image_t &img, const recti &region)
 Blits the image img onto the this image. More...

bool blend (const image_t &img, const recti &region)
 Alpha blends the image img onto the this image. More...


Detailed Description

A 2D image.

Note:
Pixels are stored internally in row major format.

Definition at line 22 of file image.h.


Member Enumeration Documentation

enum image::image_t::bpc
 

Bits per channel.

Enumeration values:
BYTE  8 bits (unsigned char).
WORD  32 bits (float).
DWORD  64 bits (double).

Definition at line 34 of file image.h.

enum image::image_t::format
 

Format the pixels are stored in.

Enumeration values:
GREYSCALE  Greyscale.
RGB  Red Green Blue.
RGBA  Red Green Blue Alpha.

Definition at line 26 of file image.h.


Constructor & Destructor Documentation

image::image_t::image_t unsigned int    width,
unsigned int    height,
format    fmat,
unsigned int    depth
 

Constructor.

Parameters:
width  Width of image.
height  Height of image.
fmat  Format of image. One of image::GREYSCALE, image::RGB, or image::RGBA.
depth  Bits per channel. One of 8, 32, 64.

Definition at line 8 of file image.cpp.

References BYTE.

image::image_t::image_t unsigned int    width,
unsigned int    height,
format    fmat,
unsigned int    depth,
const void *    pixels
 

Constructor.

Parameters:
width  Width of image.
height  Height of image.
fmat  Format of image. One of GREYSCALE, RGB, or RGBA.
depth  Bits per channel. One of 8, 32, 64.
pixels  Pointer to pixel data. Pixel data will be copied.

Definition at line 41 of file image.cpp.

References BYTE.


Member Function Documentation

bool image::image_t::blend const image_t &    img,
const recti &    region
 

Alpha blends the image img onto the this image.

Parameters:
img  Image to blit onto this surface.
region  Rectangle where to blit on this surface.
Returns:
true if the blit was successful.

Definition at line 572 of file image.cpp.

References blend_pixel, rectangle::x, and rectangle::y.

bool image::image_t::blit const image_t &    img,
const recti &    region
 

Blits the image img onto the this image.

Parameters:
img  Image to blit onto this surface.
region  Rectangle where to blit on this surface.
Returns:
true if the blit was successful.

Definition at line 553 of file image.cpp.

References set_pixel, rectangle::x, and rectangle::y.

Referenced by gl::ttf::load.

bool image::image_t::get_pixel unsigned char &    r,
unsigned char &    g,
unsigned char &    b,
unsigned char &    a,
unsigned int    x,
unsigned int    y
const
 

Gets the pixel at x, y.

Note:
If pixel data is not stored internally as unsigned chars or * int RGBA format, a conversion is done dynamically.
Parameters:
r  Red Channel
g  Green Channel
b  Blue Channel
x  Column of pixel to get.
y  Row of pixel to get.
Returns:
true if the read was successful.

Definition at line 365 of file image.cpp.

References RGB, and RGBA.

bool image::image_t::get_pixel unsigned char &    r,
unsigned char &    g,
unsigned char &    b,
unsigned int    x,
unsigned int    y
const
 

Gets the pixel at x, y.

Note:
If pixel data is not stored internally as unsigned chars or * int RGB format, a conversion is done dynamically.
Parameters:
r  Red Channel
g  Green Channel
b  Blue Channel
x  Column of pixel to get.
y  Row of pixel to get.
Returns:
true if the read was successful.

Definition at line 334 of file image.cpp.

References RGB, and RGBA.

bool image::image_t::read unsigned char &    r,
unsigned char &    g,
unsigned char &    b,
unsigned char &    a
 

Reads the current pixel in the image.

Reads the pixel at the current seek position. After the read, the the current seek position is moved to the next pixel.

Parameters:
r  Red Channel
g  Green Channel
b  Blue Channel
a  Alpha Channel
Returns:
true if the pixel was successfully read.

Definition at line 177 of file image.cpp.

References RGB, and RGBA.

bool image::image_t::read unsigned char &    r,
unsigned char &    g,
unsigned char &    b
 

Reads the current pixel in the image.

Reads the pixel at the current seek position. After the read, the the current seek position is moved to the next pixel.

Parameters:
r  Red Channel
g  Green Channel
b  Blue Channel
Returns:
true if the pixel was successfully read.

Definition at line 145 of file image.cpp.

References RGB, and RGBA.

bool image::image_t::read unsigned char &    gray
 

Reads the current pixel in the image.

Reads the pixel at the current seek position. After the read, the the current seek position is moved to the next pixel.

Parameters:
gray  Gray Channel
Returns:
true if the pixel was successfully read.

Definition at line 105 of file image.cpp.

References RGB, and RGBA.

bool image::image_t::seek unsigned int    x,
unsigned int    y
 

Seeks to the pixel at x, y.

Returns:
true if the seek was successful.

Definition at line 84 of file image.cpp.

Referenced by gl::ttf::load.

bool image::image_t::set_pixel unsigned char    r,
unsigned char    g,
unsigned char    b,
unsigned char    a,
unsigned int    x,
unsigned int    y
 

Sets the pixel at x, y.

Note:
If pixel data is not stored internally as unsigned chars or * int RGBA format, a conversion is done dynamically.
Parameters:
r  Red Channel
g  Green Channel
b  Blue Channel
x  Column of pixel to set.
y  Row of pixel to set.
Returns:
true if the write was successful.

Definition at line 438 of file image.cpp.

References RGB, and RGBA.

bool image::image_t::set_pixel unsigned char    r,
unsigned char    g,
unsigned char    b,
unsigned int    x,
unsigned int    y
 

Sets the pixel at x, y.

Note:
If pixel data is not stored internally as unsigned chars or * int RGB format, a conversion is done dynamically.
Parameters:
r  Red Channel
g  Green Channel
b  Blue Channel
x  Column of pixel to set.
y  Row of pixel to set.
Returns:
true if the write was successful.

Definition at line 405 of file image.cpp.

References RGB, and RGBA.

Referenced by blit.

bool image::image_t::write unsigned char    r,
unsigned char    g,
unsigned char    b,
unsigned char    a
 

Sets the current pixel in the image.

Sets the pixel at the current seek position. After the write, the the current seek position is moved to the next pixel.

Parameters:
r  Red Channel
g  Green Channel
b  Blue Channel
a  Alpha Channel
Returns:
true if the pixel was successfully written.

Definition at line 292 of file image.cpp.

References RGB, and RGBA.

bool image::image_t::write unsigned char    r,
unsigned char    g,
unsigned char    b
 

Sets the current pixel in the image.

Sets the pixel at the current seek position. After the write, the the current seek position is moved to the next pixel.

Parameters:
r  Red Channel
g  Green Channel
b  Blue Channel
Returns:
true if the pixel was successfully written.

Definition at line 258 of file image.cpp.

References RGB, and RGBA.

bool image::image_t::write unsigned char    gray
 

Sets the current pixel in the image.

Sets the pixel at the current seek position. After the write, the the current seek position is moved to the next pixel.

Parameters:
gray  Gray Channel
Returns:
true if the pixel was successfully written.

Definition at line 219 of file image.cpp.

References RGB, and RGBA.

Referenced by gl::ttf::load.


Generated on Tue Feb 11 18:49:49 2003 for uber by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002