Beatmup
Beatmup::GDIBitmap Class Reference

A simple wrapper of GDI bitmap. More...

#include <gdi_bitmap.h>

Inheritance diagram for Beatmup::GDIBitmap:
Beatmup::AbstractBitmap Beatmup::GL::TextureHandler Beatmup::Object

Classes

class  Impl
 A simple wrapper of IL image. More...
 

Public Member Functions

 GDIBitmap (Context &ctx, const wchar_t *filename)
 
 GDIBitmap (Context &ctx, PixelFormat format, int width, int height)
 
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...
 
int getStride () const
 
const msize getMemorySize () const
 Bitmap size in bytes. More...
 
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...
 
const pixbytegetData (int x, int y) const
 Returns a pointer to given pixel. More...
 
void save (const wchar_t *filename)
 
- 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...
 
virtual pixbytegetData (int x, int y)=0
 
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...
 
ContextgetContext () 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 Attributes

Implimpl
 

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
Contextctx
 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
 

Detailed Description

A simple wrapper of GDI bitmap.

Definition at line 31 of file gdi_bitmap.h.

Constructor & Destructor Documentation

◆ GDIBitmap() [1/2]

GDIBitmap::GDIBitmap ( Context ctx,
const wchar_t *  filename 
)

Definition at line 167 of file gdi_bitmap.cpp.

167  :
169 {
170  impl = new Impl(ctx, filename);
171 }
Context & ctx
context managing this bitmap
AbstractBitmap(const AbstractBitmap &that)=delete
disabling copying constructor
JNIEnv jlong jstring filename

◆ GDIBitmap() [2/2]

GDIBitmap::GDIBitmap ( Context ctx,
PixelFormat  format,
int  width,
int  height 
)

Definition at line 174 of file gdi_bitmap.cpp.

174  : AbstractBitmap(ctx) {
175  impl = new Impl(ctx, width, height, format);
176 }
JNIEnv jobject jint format
jlong jint width
jlong jint jint height

Member Function Documentation

◆ getPixelFormat()

const PixelFormat GDIBitmap::getPixelFormat ( ) const
virtual

Pixel format of the bitmap.

Implements Beatmup::AbstractBitmap.

Definition at line 179 of file gdi_bitmap.cpp.

179  {
180  return impl->getPixelFormat();
181 }
const PixelFormat getPixelFormat() const
Definition: gdi_bitmap.cpp:112

◆ getWidth()

const int GDIBitmap::getWidth ( ) const
virtual

Width of the texture in pixels.

Implements Beatmup::GL::TextureHandler.

Definition at line 184 of file gdi_bitmap.cpp.

184  {
185  return impl->getWidth();
186 }
const int getWidth() const
Definition: gdi_bitmap.cpp:122

◆ getHeight()

const int GDIBitmap::getHeight ( ) const
virtual

Height of the texture in pixels.

Implements Beatmup::GL::TextureHandler.

Definition at line 189 of file gdi_bitmap.cpp.

189  {
190  return impl->getHeight();
191 }
const int getHeight() const
Definition: gdi_bitmap.cpp:127

◆ getStride()

int GDIBitmap::getStride ( ) const

Definition at line 194 of file gdi_bitmap.cpp.

194  {
195  return impl->getStride();
196 }

◆ getMemorySize()

const msize GDIBitmap::getMemorySize ( ) const
virtual

Bitmap size in bytes.

Implements Beatmup::AbstractBitmap.

Definition at line 199 of file gdi_bitmap.cpp.

199  {
200  return getBitsPerPixel() * getWidth() * getHeight() / 8;
201 }
const unsigned char getBitsPerPixel() const
Returns number of bits per pixel stored in each bitmap.
const int getHeight() const
Height of the texture in pixels.
Definition: gdi_bitmap.cpp:189
const int getWidth() const
Width of the texture in pixels.
Definition: gdi_bitmap.cpp:184

◆ lockPixelData()

void GDIBitmap::lockPixelData ( )
virtual

Locks access to the CPU memory buffer containing pixel data.

Implements Beatmup::AbstractBitmap.

Definition at line 204 of file gdi_bitmap.cpp.

204  {
205  impl->lockPixelData();
206 }

◆ unlockPixelData()

void GDIBitmap::unlockPixelData ( )
virtual

Unlocks access to the CPU memory buffer containing pixel data.

Implements Beatmup::AbstractBitmap.

Definition at line 209 of file gdi_bitmap.cpp.

209  {
211 }

◆ getData()

const pixbyte * GDIBitmap::getData ( int  x,
int  y 
) const
virtual

Returns a pointer to given pixel.

Parameters
xtarget pixel horizontal coordinate
ytarget pixel vertical coordinate
Returns
a pointer, may be NULL.

Implements Beatmup::AbstractBitmap.

Definition at line 214 of file gdi_bitmap.cpp.

214  {
215  return impl->getData(x, y);
216 }
const pixbyte * getData(int x, int y) const
Definition: gdi_bitmap.cpp:147
jobject jlong jint jint y
jobject jlong jint x

◆ save()

void GDIBitmap::save ( const wchar_t *  filename)

Definition at line 219 of file gdi_bitmap.cpp.

219  {
220  impl->save(filename);
221 }
void save(const WCHAR *filename)
Definition: gdi_bitmap.cpp:152

Member Data Documentation

◆ impl

Impl* Beatmup::GDIBitmap::impl
private

Definition at line 34 of file gdi_bitmap.h.


The documentation for this class was generated from the following files: