|
degate 0.1.1
|
Storage policy for image objects that consists of tiles. More...
#include <TileImage.h>

Public Types | |
| typedef std::tr1::shared_ptr < MemoryMap< typename PixelPolicy::pixel_type > > | MemoryMap_shptr |
Public Member Functions | |
| StoragePolicy_Tile (unsigned int _width, unsigned int _height, std::string const &_directory, bool _persistent=false, unsigned int _tile_width_exp=10) | |
| The constructor for a tile based image. | |
| virtual | ~StoragePolicy_Tile () |
| The destructor. | |
| unsigned int | get_tile_size () const |
| Get the width / height of a single tile. | |
| std::string | get_directory () const |
| Get the directory, where images are stored. | |
| bool | is_persistent () const |
| Check if the image is persistent. | |
| PixelPolicy::pixel_type | get_pixel (unsigned int x, unsigned int y) const |
| Get pixel for "native" pixel types. | |
| void | set_pixel (unsigned int x, unsigned int y, typename PixelPolicy::pixel_type new_val) |
| Set "native" pixel. | |
| void | raw_copy (void *dst_buf, unsigned int src_x, unsigned int src_y) const |
| Copy the raw data from an image tile that has its upper left corner at x,y into a buffer. | |
Private Member Functions | |
| unsigned int | calc_real_size (unsigned int requested_size, unsigned int tile_width_exp) const |
| Get the minimum width or height of an tile based image, that it at least requested_size pixel width / height. | |
Private Attributes | |
| const bool | persistent |
| const unsigned int | tile_width_exp |
| const unsigned int | offset_bitmask |
| const std::string | directory |
| TileCache< PixelPolicy > | tile_cache |
Storage policy for image objects that consists of tiles.
This implementation uses a TileCache.
Definition at line 40 of file TileImage.h.
| typedef std::tr1::shared_ptr<MemoryMap<typename PixelPolicy::pixel_type> > degate::StoragePolicy_Tile< PixelPolicy >::MemoryMap_shptr |
Definition at line 44 of file TileImage.h.
| degate::StoragePolicy_Tile< PixelPolicy >::StoragePolicy_Tile | ( | unsigned int | _width, |
| unsigned int | _height, | ||
| std::string const & | _directory, | ||
| bool | _persistent = false, |
||
| unsigned int | _tile_width_exp = 10 |
||
| ) | [inline] |
The constructor for a tile based image.
The constructed image has at least the size specified via the width and height parameter. Because the image is splitted into equisized tiles the constructed image might be larger than the requested size.
| _width | The minimum width of the image. |
| _height | The minimum height of the image. |
| _directory | A tile based image is stored in multiple files. This directory specifies the place where the files are stored. If the directory doen't exits, it is created. |
| _persistent | This boolean value indicates whether the image files are removed on object destruction. |
| _tile_width_exp | The width (and height) for image tiles. This value is specified as an exponent to the base 2. This means for example that if you want to use a width of 1024 pixel, you have to give a value of 10, because 2^10 is 1024. |
Definition at line 102 of file TileImage.h.
References degate::create_directory(), and degate::file_exists().
:
persistent(_persistent),
tile_width_exp(_tile_width_exp),
offset_bitmask((1 << _tile_width_exp) - 1),
directory(_directory),
tile_cache(_directory, _tile_width_exp, _persistent) {
if(!file_exists(_directory)) create_directory(_directory);
}

| virtual degate::StoragePolicy_Tile< PixelPolicy >::~StoragePolicy_Tile | ( | ) | [inline, virtual] |
The destructor.
Definition at line 119 of file TileImage.h.
References degate::StoragePolicy_Tile< PixelPolicy >::directory, degate::StoragePolicy_Tile< PixelPolicy >::persistent, and degate::remove_directory().
{
if(persistent == false) remove_directory(directory);
}

| unsigned int degate::StoragePolicy_Tile< PixelPolicy >::calc_real_size | ( | unsigned int | requested_size, |
| unsigned int | tile_width_exp | ||
| ) | const [inline, private] |
Get the minimum width or height of an tile based image, that it at least requested_size pixel width / height.
| requested_size | The minimum size. |
| tile_width_exp | The exponent (to base 2) that gives th |
Definition at line 71 of file TileImage.h.
References degate::StoragePolicy_Tile< PixelPolicy >::tile_width_exp.
{
// we can't use the get_tile_size() method here, because we use
// this method during the base class constructor call.
unsigned int tile_size = (1 << tile_width_exp);
unsigned int remainder = requested_size % tile_size;
if(remainder == 0) return requested_size;
else return requested_size - remainder + tile_size;
}
| std::string degate::StoragePolicy_Tile< PixelPolicy >::get_directory | ( | ) | const [inline] |
Get the directory, where images are stored.
Definition at line 136 of file TileImage.h.
References degate::StoragePolicy_Tile< PixelPolicy >::directory.
{ return directory; }
| PixelPolicy::pixel_type degate::StoragePolicy_Tile< PixelPolicy >::get_pixel | ( | unsigned int | x, |
| unsigned int | y | ||
| ) | const [inline, virtual] |
Get pixel for "native" pixel types.
This method is abstract. If you derive from this class, you should implement it for a concrete StoragePolicy.
Implements degate::StoragePolicy_Base< PixelPolicy >.
Definition at line 161 of file TileImage.h.
{
MemoryMap_shptr mem = tile_cache.get_tile(x, y);
return mem->get(x & offset_bitmask, y & offset_bitmask);
}
| unsigned int degate::StoragePolicy_Tile< PixelPolicy >::get_tile_size | ( | ) | const [inline] |
Get the width / height of a single tile.
The size is a power of two.
Definition at line 128 of file TileImage.h.
References degate::StoragePolicy_Tile< PixelPolicy >::tile_width_exp.
{
return (1 << tile_width_exp);
}
| bool degate::StoragePolicy_Tile< PixelPolicy >::is_persistent | ( | ) | const [inline] |
Check if the image is persistent.
Definition at line 141 of file TileImage.h.
References degate::StoragePolicy_Tile< PixelPolicy >::persistent.
{ return persistent; }
| void degate::StoragePolicy_Tile< PixelPolicy >::raw_copy | ( | void * | dst_buf, |
| unsigned int | src_x, | ||
| unsigned int | src_y | ||
| ) | const [inline] |
Copy the raw data from an image tile that has its upper left corner at x,y into a buffer.
Definition at line 151 of file TileImage.h.
References degate::StoragePolicy_Tile< PixelPolicy >::tile_cache.
{
MemoryMap_shptr mem = tile_cache.get_tile(src_x, src_y);
mem->raw_copy(dst_buf);
}
| void degate::StoragePolicy_Tile< PixelPolicy >::set_pixel | ( | unsigned int | x, |
| unsigned int | y, | ||
| typename PixelPolicy::pixel_type | new_val | ||
| ) | [inline, virtual] |
Set "native" pixel.
This method is abstract. If you derive from this class, you should implement it for a concrete StoragePolicy.
Implements degate::StoragePolicy_Base< PixelPolicy >.
Definition at line 169 of file TileImage.h.
{
MemoryMap_shptr mem = tile_cache.get_tile(x, y);
mem->set(x & offset_bitmask, y & offset_bitmask, new_val);
}
const std::string degate::StoragePolicy_Tile< PixelPolicy >::directory [private] |
Definition at line 56 of file TileImage.h.
Referenced by degate::StoragePolicy_Tile< PixelPolicy >::get_directory(), and degate::StoragePolicy_Tile< PixelPolicy >::~StoragePolicy_Tile().
const unsigned int degate::StoragePolicy_Tile< PixelPolicy >::offset_bitmask [private] |
Definition at line 53 of file TileImage.h.
const bool degate::StoragePolicy_Tile< PixelPolicy >::persistent [private] |
Definition at line 49 of file TileImage.h.
Referenced by degate::StoragePolicy_Tile< PixelPolicy >::is_persistent(), and degate::StoragePolicy_Tile< PixelPolicy >::~StoragePolicy_Tile().
TileCache<PixelPolicy> degate::StoragePolicy_Tile< PixelPolicy >::tile_cache [mutable, private] |
Definition at line 59 of file TileImage.h.
Referenced by degate::StoragePolicy_Tile< PixelPolicy >::raw_copy().
const unsigned int degate::StoragePolicy_Tile< PixelPolicy >::tile_width_exp [private] |
Definition at line 52 of file TileImage.h.
Referenced by degate::StoragePolicy_Tile< PixelPolicy >::calc_real_size(), and degate::StoragePolicy_Tile< PixelPolicy >::get_tile_size().
1.7.4