#include <media/bmapdata.h>
Public Types | |
enum | row_order { TOP_FIRST, BOTTOM_FIRST } |
Specifies the order in which the rows are physically arranged in memory. | |
Public Member Functions | |
bmap_data () | |
Construct with empty image data. | |
bmap_data (const geom::vec2< int > &dims, int bits_per_pixel, int byte_alignment) | |
Construct with the given image data specifications. | |
bmap_data (const bmap_data &other) | |
Copy constructor. | |
bmap_data & | operator= (const bmap_data &other) |
Assignment operator. | |
~bmap_data () | |
Destructor frees Impl*. | |
unsigned char * | bytes_ptr () const |
Returns a pointer to the raw image data. | |
unsigned char * | row_ptr (unsigned int row) const |
Returns a pointer to the beginning of the specified row. | |
long int | bytes_sum () const |
Returns a checksum of all the bytes in the image data. | |
int | width () const |
Returns the bitmap's width in pixels. | |
int | height () const |
Returns the bitmap's height in pixels. | |
geom::vec2< int > | size () const |
Returns the bitmap's size (x-width, y-height) in pixels. | |
int | bits_per_pixel () const |
Returns the number of bits used per pixel in the bitmap. | |
int | bits_per_component () const |
Returns the number of bits used per each pixel component. | |
int | byte_alignment () const |
Returns the byte alignment of the bitmap data. | |
unsigned int | byte_count () const |
Returns the number of bytes used by the bitmap data. | |
unsigned int | bytes_per_row () const |
Returns the number of bytes used per image row in the bitmap data. | |
row_order | get_row_order () const |
Get the current row order. | |
void | flip_contrast () |
Flips the image contrast of the bitmap data. | |
void | flip_vertical () |
Flips the image vertically. | |
void | clear () |
Clears the bitmap data, erasing the current image. | |
void | swap (bmap_data &other) |
Swaps the internal representation with that of other. | |
void | queue_update (rutz::shared_ptr< update_func > updater) const |
Queues the update given by updater. | |
void | update_if_needed () const |
Forces any pending update to be called. | |
void | clear_queued_update () const |
Cancels any pending update. | |
void | set_row_order (row_order order) const |
Set the row order, swapping rows around in memory if necessary. | |
void | specify_row_order (row_order order) const |
Specify the row order but leave the actual memory untouched. | |
rutz::shared_ptr< bmap_data > | make_scrambled (int numsubcols, int numsubrows, int seed, bool allow_move_subparts=true, bool allow_flip_left_right=true, bool allow_flip_top_bottom=true) const |
Generate a new image from scrambled subparts of the current image. | |
Classes | |
class | impl |
class | update_func |
Nested class in allows bmap_data objects to be updated lazily. More... |
media::bmap_data
handles the low-level details of manipulating bitmap data. It keeps track of the width, height, bits-per-pixel, and storage alignemnt requirements of a chunk of image data. In addition, media::bmap_data
provides for lazy updates via the update_func
class. Clients may subclass update_func
to implement update_func::update()
, then pass this type of object to queue_update()
. Then the update()
function will be called only when the bitmap data need to be accessed.
Definition at line 65 of file bmapdata.h.
unsigned char * media::bmap_data::row_ptr | ( | unsigned int | row | ) | const |
Returns a pointer to the beginning of the specified row.
This takes into account whether the current row_order is TOP_FIRST or BOTTOM_FIRST.
Definition at line 160 of file bmapdata.cc.
References update_if_needed().
int media::bmap_data::bits_per_component | ( | ) | const |
Returns the number of bits used per each pixel component.
This differs from bits_per_pixel() if each pixel contains multiple components (e.g. as in an RGB image): the bits_per_component() might be 8 while the bits_per_pixel() would be 24.
Definition at line 212 of file bmapdata.cc.
References update_if_needed().
int media::bmap_data::byte_alignment | ( | ) | const |
Returns the byte alignment of the bitmap data.
Each image row in the data will begin on a multiple of this number of bytes.
Definition at line 221 of file bmapdata.cc.
References update_if_needed().
Referenced by make_scrambled().
unsigned int media::bmap_data::byte_count | ( | ) | const |
Returns the number of bytes used by the bitmap data.
Some of these bytes may be 'filler bytes' needed to meet the storage alignment requirements.
Definition at line 228 of file bmapdata.cc.
References update_if_needed().
Referenced by bytes_sum(), and Gabor::getBmapData().
void media::bmap_data::queue_update | ( | rutz::shared_ptr< update_func > | updater | ) | const |
Queues the update given by updater.
The update()
function will be called only when the bitmap data must be accessed.
Definition at line 315 of file bmapdata.cc.
void media::bmap_data::set_row_order | ( | row_order | order | ) | const |
Set the row order, swapping rows around in memory if necessary.
This is a logical "const" operation since the image being represented stays the same; only its representation changes.
Definition at line 343 of file bmapdata.cc.
References flip_vertical().