Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

Bitmap Class Reference

List of all members.

Detailed Description

A 2d matrix of RGBA values.


Public Types

enum  RasterOp { Copy, XOR }
 A raster transfer mode. More...


Public Member Functions

 this (int width, int height)
 Create a bitmap.

bit inRange (int x, int y)
 Determine whether this point is in-range.

bit inRangeX (int x)
 Determine whether the horizontal coordinate is in-range.

bit inRangeY (int y)
 Determine whether the vertical coordinate is in-range.

Color get (int x, int y)
 Read a pixel from the bitmap.

Color getx (int x, int y)
 Read a pixel from the bitmap, assuming it's in-range.

void set (int x, int y, Color c)
 Store a pixel in the bitmap.

void hseto (int sx, int y, Color[] colors)
 Set a horizontal row on the bitmap, no blending.

int width ()
 The width of the bitmap in pixels.

int height ()
 The height of the bitmap in pixels.

void clear (Color c)
 Clear to a single color.

void rect (int sx, int sy, int ex, int ey, Brush brush)
 Draw a rectangle on the bitmap using pen around the edges and brush inside.

void outlineRect (int sx, int sy, int ex, int ey, Brush brush)
 Draw an outline rectangle, inclusive.

void hline (int sx, int y, int ex, Brush brush)
 Draw a horizontal line, inclusive.

void vline (int x, int sy, int ey, Brush brush)
 Draw a vertical line, inclusive.

void arect (int sx, int sy, int ex, int ey, Color color)
 Draw a non-blended filled rectangle.

void polygon (float p[], Brush brush)
 Draw a filled polygon using a single loop.

void line (float sx, float sy, float ex, float ey, Brush brush)
 Draw a line on the bitmap using the current pen.

void blit (Canvas canvas, int x, int y)
 Blit the bitmap onto the canvas.

void blit (Canvas canvas, int x, int y, RasterOp mode)
 Blit the bitmap onto the canvas.

void blit (Canvas canvas, int x, int y, int sourcex, int sourcey, int width, int height)
 Blit the bitmap onto the canvas, specifying the region to blit from.

void blit (Canvas canvas, int x, int y, int sourcex, int sourcey, int width, int height, RasterOp mode)
 Blit the bitmap onto the canvas, specifying the region to blit from.

void stretchBlit (Canvas canvas, int dx, int dy, int dw, int dh, int sx, int sy, int sw, int sh)
 Blit contents of this bitmap onto the canvas while stretching its dimensions.

void stretchBlit (Canvas canvas, int dx, int dy, int dw, int dh)
 Blit the entire contents of this bitmap onto the canvas while stretching its dimensions.

void stretchBlit (Bitmap dest, int dx, int dy, int dw, int dh, int sx, int sy, int sw, int sh)
 Blit contents of this bitmap on another bitmap while stretching its dimensions.

void circlePoint (inout float[] points, float px, float py, float x, float y, float w, float h, float a, float b)
 Create the set of points for a circle, recursively subdividing as needed to handle non-linear distortions.

void circle (float x, float y, float radius, Brush brush)
 Call circle (x, y, radius, radius, brush).

void circle (float x, float y, float w, float h, Brush brush)
 Draw an ellipse on the bitmap.

ubyte * row (int x, int y)
 Return pointer to this row's data.

void boundx (inout int x)
 If x is out-of-range, saturate it to the edges.

void boundy (inout int y)
 If y is out-of-range, saturate it to the edges.

void bound (inout int x, inout int y)
 If x or y are out-of-range, saturate them to the edges.


Static Public Member Functions

void store (ubyte *data, Color color)
 Store a color into a data pointer.

void storeinc (inout ubyte *data, Color color)
 Store a color into a data point and increment the pointer.

Color retrieve (ubyte *data)
 Retrieve a color from a data pointer.

Color retrieveinc (inout ubyte *data)
 Retrieve a color from a data pointer and increment the pointer.


Public Attributes

const int bytesPerPixel = 4
 The number of bytes to a pixel.

Contorter contort
 The contorter to use for polygon points and pixels rendered to the bitmap.


Related Functions

(Note that these are not member functions.)

Bitmap BitmapLoad (char[] filename, Stream stream)
 Read an image file from a stream and return a bitmap.


Member Enumeration Documentation

enum Bitmap::RasterOp
 

A raster transfer mode.

Enumeration values:
Copy  Copy colors between the source and the destination (destination = source).
XOR  Binary exclusive-or the colors in the color-space (destination = destination ^ source).


Member Function Documentation

void Bitmap.blit Canvas  canvas,
int  x,
int  y,
int  sourcex,
int  sourcey,
int  width,
int  height,
RasterOp  mode
 

Blit the bitmap onto the canvas, specifying the region to blit from.

The canvas must be in between a beginPaint/endPaint pair. The alpha channel is ignored in the blit, which means if the bitmap is partially transparent the colors could come out oddly (for example, objects drawn on it that had no visual effect will show up). The solution is to either preprocess the bitmap or blit it onto another bitmap first.

Parameters:
canvas The canvas to blit onto.
x The horizontal coordinate to blit onto.
y The vertical coordinate to blit onto.
sourcex The horizontal start of the rectangle on the bitmap to blit from.
sourcey The vertical start of the rectangle on the bitmap to blit from.
width The width in pixels to blit from.
height The height in pixels to blit from.
mode The raster transfer mode to use.

void Bitmap.blit Canvas  canvas,
int  x,
int  y,
int  sourcex,
int  sourcey,
int  width,
int  height
 

Blit the bitmap onto the canvas, specifying the region to blit from.

The canvas must be in between a beginPaint/endPaint pair. The alpha channel is ignored in the blit, which means if the bitmap is partially transparent the colors could come out oddly (for example, objects drawn on it that had no visual effect will show up). The solution is to either preprocess the bitmap or blit it onto another bitmap first.

Parameters:
canvas The canvas to blit onto.
x The horizontal coordinate to blit onto.
y The vertical coordinate to blit onto.
sourcex The horizontal start of the rectangle on the bitmap to blit from.
sourcey The vertical start of the rectangle on the bitmap to blit from.
width The width in pixels to blit from.
height The height in pixels to blit from.

void Bitmap.blit Canvas  canvas,
int  x,
int  y,
RasterOp  mode
 

Blit the bitmap onto the canvas.

The canvas must be in between a beginPaint/endPaint pair. The alpha channel is ignored in the blit, which means that if the bitmap is partially transparent the colors could come out oddly (for example, objects drawn on it that had no visual effect will show up). The solution is to either preprocess the bitmap or blit it onto another bitmap first.

Parameters:
canvas The canvas to blit onto.
x The horizontal coordinate to blit onto.
y The vertical coordinate to blit onto.
mode The raster transfer mode to use.

void Bitmap.blit Canvas  canvas,
int  x,
int  y
 

Blit the bitmap onto the canvas.

The canvas must be in between a beginPaint/endPaint pair. The alpha channel is ignored in the blit, which means that if the bitmap is partially transparent the colors could come out oddly (for example, objects drawn on it that had no visual effect will show up). The solution is to either preprocess the bitmap or blit it onto another bitmap first.

Parameters:
canvas The canvas to blit onto.
x The horizontal coordinate to blit onto.
y The vertical coordinate to blit onto.

void Bitmap.circle float  x,
float  y,
float  w,
float  h,
Brush  brush
 

Draw an ellipse on the bitmap.

Parameters:
x The center horizontal coordinate.
y The vertical horizontal coordinate.
w The horizontal radius of the ellipse.
h The vertical radius of the ellipse.
brush The brush to use for coloring.

Color Bitmap.get int  x,
int  y
 

Read a pixel from the bitmap.

If out-of-range, this returns black.

void Bitmap.line float  sx,
float  sy,
float  ex,
float  ey,
Brush  brush
 

Draw a line on the bitmap using the current pen.

This creates square caps on the ends of the line.

Parameters:
sx The horizontal starting coordinate of the line.
sy The vertical starting coordinate of the line.
ex The horizontal ending coordinate of the line.
ey The vertical ending coordinate of the line.
brush The brush to use for fill and pen parameters.

void Bitmap.polygon float  p[],
Brush  brush
 

Draw a filled polygon using a single loop.

This uses odd/even fill mode; a star drawn using five points will have a hollowed-out center.

ubyte* Bitmap.row int  x,
int  y
 

Return pointer to this row's data.

Use store and retrieve to access the values. Does NO bounds checking.

void Bitmap.set int  x,
int  y,
Color  c
 

Store a pixel in the bitmap.

If it's out-of-range, it is ignored. This blends the pixel into the current color.

void Bitmap.stretchBlit Bitmap  dest,
int  dx,
int  dy,
int  dw,
int  dh,
int  sx,
int  sy,
int  sw,
int  sh
 

Blit contents of this bitmap on another bitmap while stretching its dimensions.

This chooses the nearest point. This is currently poorly implemented and will be very slow.

Parameters:
dest The bitmap to blit onto.
dx The horizontal coordinate to blit onto.
dy The vertical coordinate to blit onto.
dw The width in pixels of the region to blit onto.
dh The height in pixels of the region to blit onto.
sx The horizontal coordinate to start blitting from.
sy The vertical coordinate to start blitting from.
sw The width in pixels of the region to blit from.
sh The height in pixels of the region to blit from.

void Bitmap.stretchBlit Canvas  canvas,
int  dx,
int  dy,
int  dw,
int  dh
 

Blit the entire contents of this bitmap onto the canvas while stretching its dimensions.

Parameters:
canvas The canvas to blit onto.
dx The starting horizontal coordinate to blit onto.
dy The starting vertical coordinate to blit onto.
dw The width in pixels to render the bitmap as.
dh The height in pixels to render the bitmap as.

void Bitmap.stretchBlit Canvas  canvas,
int  dx,
int  dy,
int  dw,
int  dh,
int  sx,
int  sy,
int  sw,
int  sh
 

Blit contents of this bitmap onto the canvas while stretching its dimensions.

Parameters:
canvas The canvas to blit onto.
dx The starting horizontal coordinate to blit onto.
dy The starting vertical coordinate to blit onto.
dw The width in pixels to render the bitmap as.
dh The height in pixels to render the bitmap as.
sx The horizontal coordinate in the bitmap to start blitting from.
sy The vertical coordinate in the bitmap to start blitting from.
sw The width in pixels of the region to blit from.
sh The height in pixels of the region to blit from.

Bitmap.this int  width,
int  height
 

Create a bitmap.

Make it compatible with the Control and have the specified dimensions.


Friends And Related Function Documentation

Bitmap BitmapLoad charfilename  [],
Stream  stream
[related]
 

Read an image file from a stream and return a bitmap.

filename will be used for error messages only.


The documentation for this class was generated from the following files:
Generated on Thu Sep 4 13:12:51 2003 for dig by doxygen 1.3.2