bmp



struct Color;
Holds the RGB values of a color.

ubyte red;
red component

ubyte green;
green component

ubyte blue;
blue component

class BMP;
An in memory image that can read and write to a .bmp file, or display to the screen. You can edit the individual pixels with the setPixel functions.

this(uint w, uint h, int bpp = 24);
Creates an empty image with the given width and height, in pixels. Final argument is the bits per pixel - either 8 (for indexed images) or 24 (for truecolor images) are valid options.

this(string fname);
Loads a .bmp file.

BUGS:
the .bmp must be saved as a 24 bit bitmap.

const Color getPixel(uint x, uint y);
Gets the pixel's red, green, and blue components

const uint getPixelIndex(uint x, uint y);
Returns the palette index for the pixel at x,y. Only valid on 8 bit per pixel images.

void setPixel(uint x, uint y, Color c);
Sets the pixel at x,y to the given color. Only valid on 24 bit image.

void setPixel(uint x, uint y, uint c);
Sets the pixel at x,y to the given palette index. Only valid on 8 bit image.

const Color getPaletteEntry(ubyte n);
Gets the RGB value of a given entry in the palette. Only valid on 8 bit image.

const ubyte getNearestPaletteEntry(Color c);
Finds the best match in the existing palette for the given color. NOT YET IMPLEMENTED

void setPaletteEntry(ubyte n, Color c);
Overwrites the given palette index with the given color. Only valid on 8 bit image.

void addPaletteEntry(Color c);
Allocates a new palette entry and sets it to the given color. Only valid on 8 bit image.

const uint width();
width of the image, in pixels.

const uint height();
The height of the image, in pixels.

void load(string filename);
Replaces the image data with that loaded from a given .bmp file.

BUGS:
only supports loading of 24 bit bmp.

const void save(string filename);
Saves the image to a .bmp file.

void display();
Pops up a GUI window displaying the image. Blocks until the user closes the window or presses any key in the window.

BUGS:
Extremely slow on X11.


Page generated by Ddoc.