Bitmap

Implements a bitmap with variable bit depth. Use the aliases to initialize them.

Note on 16 bit bitmaps: It's using the master palette, It's not implementing any 16 bit RGB or RGBA color space directly. Can implement such colorspaces via proper lookup tables.

Note on 4 bit bitmaps: It's width needs to be an even number (for rendering simplicity), otherwise it'll cause an exception.

Note on 1 bit bitmaps: Uses size_t based paddings for more than one bit testing at the time in the future, through the use of logic functions.

class Bitmap : ABitmap (
string S
T
) {}

Constructors

this
this(int w, int h)

Unified CTOR to create empty bitmap.

this
this(T[] src, int w, int h)

Unified CTOR tor create bitmap from preexisting data.

this
this(int x, int y)

Creates an empty bitmap.

this
this(ubyte[] p, int x, int y)

Creates a bitmap from an array.

this
this(int w, int h)

CTOR for 1 bit bitmaps with no preexisting source.

this
this(ubyte[] src, int w, int h)

CTOR to convert 8bit aligned bitmaps to 32/64bit ones.

this
this(size_t[] src, int w, int h)

CTOR for 1 bit bitmaps with a preexisting source. Alignment and padding is for size_t (32 and 64 bit, on their respected systems)

Members

Functions

clear
void clear()

Clears the Bitmap

clear
void clear()
Undocumented in source. Be warned that the author may not have intended to support it.
generateStandardCollisionModel
Bitmap1bit generateStandardCollisionModel(T transparency)

Generates a standard collision model by checking against a transparency value (default vaule is T.init).

getPtr
T* getPtr()
Undocumented in source. Be warned that the author may not have intended to support it.
offsetIndexes
void offsetIndexes(ushort offset, bool keepZerothIndex)

Offsets all indexes in the bitmap by a certain value. Keeps zeroth index (usually for transparency) if needed. Useful when converting bitmaps.

readPixel
T readPixel(int x, int y)

Returns the pixel at the given position.

readPixel
ubyte readPixel(int x, int y)

Returns the pixel at the given position.

readPixel
bool readPixel(int x, int y)

Returns the pixel at the given position.

resize
void resize(int x, int y)

Resizes the bitmap. NOTE: It's not for scaling.

resize
void resize(int x, int y)

Resizes the array behind the bitmap.

testLineCollision
bool testLineCollision(int line, Bitmap1bit other, int otherLine, int offset, uint nOfLines)

Tests a single line of pixels between two 1 bit bitmaps for collision, using a single chunk of pixels. (Unimplemented, is a placeholder as of now) * line: The (first) line, which is being tested in the current object. * other: The other object that this is being tested against. * otherLine: The (first) line, which is being tested in the other object. * offset: The horizontal offset of the other object to the right. If negative, then it's being offsetted to the left. * nOfLines: The number of lines to be tested. Must be non-zero, otherwise the test won't run.

window
Bitmap!(S, T) window(int iX0, int iY0, int iX1, int iY1)

Returns a 2D slice (window) of the bitmap.

writePixel
void writePixel(int x, int y, T color)

Writes the pixel at the given position.

writePixel
void writePixel(int x, int y, ubyte color)

Writes the pixel at the given position.

writePixel
bool writePixel(int x, int y, bool val)

Writes the pixel at the given position.

Properties

wordLengthByString
string wordLengthByString [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

invertHoriz
bool invertHoriz;

Horizontal invertion for reading and writing

invertVert
bool invertVert;

Vertical invertion for reading anr writing

pitch
size_t pitch;

Total length of a line in bits

pixelAccess
BitArray pixelAccess;
Undocumented in source.
pixels
T[] pixels;

Image data.

Inherited Members

From ABitmap

width
int width()

Returns the width of the bitmap.

height
int height()

Returns the height of the bitmap.

getPalettePtr
Color* getPalettePtr()

Returns the palette pointer.

setPalettePtr
void setPalettePtr(Color* p)

Sets the palette pointer. Make sure that you set it to a valid memory location. DEPRECATED!

wordLengthByString
string wordLengthByString()

Returns the wordlength of the type

clear
void clear()

Clears the whole bitmap to a transparent color.

Meta