Beatmup
|
Bitmap whose memory is managed by the Beatmup engine. More...
#include <internal_bitmap.h>
Public Member Functions | |
InternalBitmap (Context &ctx, PixelFormat pixelFormat, int width, int height, bool allocate=true) | |
Creates a bitmap. More... | |
InternalBitmap (Context &ctx, const char *bmpFilename) | |
Loads image from a BMP file. More... | |
void | reshape (int width, int height) |
Changes bitmap size. More... | |
const PixelFormat | getPixelFormat () const |
Pixel format of the bitmap. More... | |
const int | getWidth () const |
Width of the texture in pixels. More... | |
const int | getHeight () const |
Height of the texture in pixels. More... | |
const msize | getMemorySize () const |
Bitmap size in bytes. More... | |
const pixbyte * | getData (int x, int y) const |
Returns a pointer to given pixel. More... | |
pixbyte * | getData (int x, int y) |
Public Member Functions inherited from Beatmup::AbstractBitmap | |
virtual const int | getDepth () const |
Depth of the texture in pixels. More... | |
virtual const TextureFormat | getTextureFormat () const |
Returns the texture format specifying how the shader must interpret the data. More... | |
bool | isUpToDate (ProcessingTarget) const |
bool | isDirty () const |
Returns true if the bitmap does not contain any valid content. More... | |
int | getPixelInt (int x, int y, int cha=0) const |
Retrieves integer value of given channel at given pixel. More... | |
const unsigned char | getBitsPerPixel () const |
Returns number of bits per pixel stored in each bitmap. More... | |
const unsigned char | getNumberOfChannels () const |
Returns number of bytes per pixel stored in each bitmap. More... | |
const ImageResolution | getSize () const |
Returns the bitmap resolution within ImageResolution object. More... | |
Context & | getContext () const |
void | zero () |
Sets all the pixels to zero. More... | |
bool | isInteger () const |
Returns true if the bitmap contains integer values, false otherwise. More... | |
bool | isFloat () const |
Returns true if the bitmap contains floating point values, false otherwise. More... | |
bool | isMask () const |
Returns true if the bitmap is a mask, false otherwise. More... | |
std::string | toString () const |
Retruns a string describing the bitmap. More... | |
void | saveBmp (const char *filename) |
Saves the bitmap to a BMP file. More... | |
~AbstractBitmap () | |
Public Member Functions inherited from Beatmup::GL::TextureHandler | |
~TextureHandler () | |
float | getAspectRatio () const |
Aspect ratio of the texture. More... | |
float | getInvAspectRatio () const |
Inverse of the aspect ratio of the texture. More... | |
const bool | isFloatingPoint () const |
const int | getNumberOfChannels () const |
Returns number of channels containing in the texture. More... | |
bool | hasValidHandle () const |
Returns true if the texture handle points to a valid texture. More... | |
Public Member Functions inherited from Beatmup::Object | |
virtual | ~Object () |
Private Member Functions | |
void | lockPixelData () |
Locks access to the CPU memory buffer containing pixel data. More... | |
void | unlockPixelData () |
Unlocks access to the CPU memory buffer containing pixel data. More... | |
Private Attributes | |
PixelFormat | pixelFormat |
int | width |
int | height |
AlignedMemory | memory |
Additional Inherited Members | |
Public Types inherited from Beatmup::GL::TextureHandler | |
enum | TextureFormat { Rx8 , RGBx8 , RGBAx8 , Rx32f , RGBx32f , RGBAx32f , OES_Ext } |
Texture format, specifies how the texture should be interpreted on the shader side. More... | |
Static Public Member Functions inherited from Beatmup::AbstractBitmap | |
static bool | isInteger (PixelFormat pixelFormat) |
Returns true if a given pixel format corresponds to integer values, false otherwise. More... | |
static bool | isFloat (PixelFormat pixelFormat) |
Returns true if a given pixel format corresponds to floating point values, false otherwise. More... | |
static bool | isMask (PixelFormat pixelFormat) |
Returns true if a given pixel format corresponds to a mask, false otherwise. More... | |
Static Public Member Functions inherited from Beatmup::GL::TextureHandler | |
static const char * | textureFormatToString (const TextureFormat &) |
Static Public Attributes inherited from Beatmup::AbstractBitmap | |
static const int | NUM_PIXEL_FORMATS = 9 |
static const char * | PIXEL_FORMAT_NAMES [NUM_PIXEL_FORMATS] |
pixel format names More... | |
static const unsigned char | CHANNELS_PER_PIXEL [NUM_PIXEL_FORMATS] |
number of channels for each pixel format More... | |
static const unsigned char | BITS_PER_PIXEL [NUM_PIXEL_FORMATS] |
number of bits per pixel for each pixel format More... | |
Static Public Attributes inherited from Beatmup::GL::TextureHandler | |
static const int | TEXTURE_FORMAT_BYTES_PER_PIXEL [] |
size of a texel in bytes for different texture formats More... | |
Protected Member Functions inherited from Beatmup::AbstractBitmap | |
AbstractBitmap (Context &ctx) | |
virtual void | prepare (GraphicPipeline &gpu) |
Prepares (eventually uploads) texture data on GPU. More... | |
Protected Member Functions inherited from Beatmup::GL::TextureHandler | |
TextureHandler () | |
void | invalidate (RecycleBin &) |
Forces disposing the texture data, e.g. More... | |
Protected Attributes inherited from Beatmup::AbstractBitmap | |
Context & | ctx |
context managing this bitmap More... | |
bool | upToDate [2] |
bitmap up-to-date state on CPU and GPU More... | |
Protected Attributes inherited from Beatmup::GL::TextureHandler | |
handle_t | textureHandle |
Bitmap whose memory is managed by the Beatmup engine.
Main pixel data container used internally by Beatmup. Applications would typically use a different incarnation of AbstractBitmap implementing I/O operations, and InternalBitmap instances are used to exchange data between different processing entities (AbstractTask instances) within the application.
Definition at line 35 of file internal_bitmap.h.
InternalBitmap::InternalBitmap | ( | Context & | ctx, |
PixelFormat | pixelFormat, | ||
int | width, | ||
int | height, | ||
bool | allocate = true |
||
) |
Creates a bitmap.
The new bitmap created this way is "dirty" (contains random content). It is up to the application to fill it with a content (e.g., set to zero).
ctx | A Beatmup context instance |
pixelFormat | Pixel format |
width | Bitmap width in pixels |
height | Bitmap height in pixels |
allocate | If true , a storage is allocated in RAM. Otherwise the allocation is deferred till the first use of the bitmap data by CPU. It is convenient to not allocate if the bitmap is only used as a texture handler to store intremediate data when processing on GPU. |
Definition at line 27 of file internal_bitmap.cpp.
InternalBitmap::InternalBitmap | ( | Context & | ctx, |
const char * | bmpFilename | ||
) |
Loads image from a BMP file.
ctx | A Beatmup context instance |
bmpFilename | Name of the .bmp file to be loaded Raises exceptions if the input file is not readable or not a valid BMP image. |
Definition at line 41 of file internal_bitmap.cpp.
|
privatevirtual |
Locks access to the CPU memory buffer containing pixel data.
Implements Beatmup::AbstractBitmap.
Definition at line 123 of file internal_bitmap.cpp.
|
inlineprivatevirtual |
Unlocks access to the CPU memory buffer containing pixel data.
Implements Beatmup::AbstractBitmap.
Definition at line 42 of file internal_bitmap.h.
void Beatmup::InternalBitmap::reshape | ( | int | width, |
int | height | ||
) |
Changes bitmap size.
Reallocates the memory if necessary. Bitmap becomes "dirty" (contains no valid content).
[in] | width | New width in pixels |
[in] | height | New height in pixels |
Definition at line 74 of file internal_bitmap.cpp.
|
virtual |
Pixel format of the bitmap.
Implements Beatmup::AbstractBitmap.
Definition at line 93 of file internal_bitmap.cpp.
|
virtual |
Width of the texture in pixels.
Implements Beatmup::GL::TextureHandler.
Definition at line 98 of file internal_bitmap.cpp.
|
virtual |
Height of the texture in pixels.
Implements Beatmup::GL::TextureHandler.
Definition at line 103 of file internal_bitmap.cpp.
|
virtual |
Bitmap size in bytes.
Implements Beatmup::AbstractBitmap.
Definition at line 108 of file internal_bitmap.cpp.
|
virtual |
Returns a pointer to given pixel.
x | target pixel horizontal coordinate |
y | target pixel vertical coordinate |
Implements Beatmup::AbstractBitmap.
Definition at line 114 of file internal_bitmap.cpp.
|
virtual |
|
private |
Definition at line 37 of file internal_bitmap.h.
|
private |
Definition at line 38 of file internal_bitmap.h.
|
private |
Definition at line 38 of file internal_bitmap.h.
|
private |
Definition at line 39 of file internal_bitmap.h.