DynRPG  v0.14a
RM2k3 Plugin SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Static Public Member Functions | Public Attributes
RPG::Canvas Class Reference

Image buffer with 16 bit color depth, used as canvas for multiple 8-bit images More...

List of all members.

Public Member Functions

unsigned short & pixel (int x, int y)
 Returns a reference to a pixel.
unsigned short * getScanline (int y)
 Returns a pointer to a row of pixel data.
int width ()
 Returns the width of the bitmap.
int height ()
 Returns the height of the bitmap.
void draw (int x, int y, RPG::Image *image, int srcX=0, int srcY=0, int srcWidth=-1, int srcHeight=-1)
 Draws an RPG::Image or a part of it onto the canvas.
void drawStretched (int x, int y, int width, int height, RPG::Image *image, int srcX=0, int srcY=0, int srcWidth=-1, int srcHeight=-1)
 Draws an RPG::Image or a part of it onto the canvas, stretched to a certain rectangle.
void drawCenteredZoomed (int x, int y, double zoomX, double zoomY, RPG::Image *image, int srcX=0, int srcY=0, int srcWidth=-1, int srcHeight=-1)
 Draws an RPG::Image or a part of it onto the canvas, centered to a certain point, and zooms it as specified.

Static Public Member Functions

static unsigned int convert16To24Bit (unsigned short pixel16)
 Converts a 16-bit pixel value to 24 bit.
static unsigned int convert16To32Bit (unsigned short pixel16)
 Converts a 16-bit pixel value to 32 bit with 100% opacity.
static unsigned short convert24To16Bit (unsigned int pixel24)
 Converts a 24-bit pixel value to 16 bit.
static unsigned short convert32To16Bit (unsigned int pixel32, unsigned short prevPixel16)
 Converts a 32-bit pixel value to 16 bit by combining it with an existing pixel.

Public Attributes

DBitmapbitmap
 Underlying 16-bit bitmap.
int lineSize
 Number of bytes you have to add to a pixel address to get the address of the pixel in the same column of the next pixel row (see details)
int brightness
 Brightness of the screen (see details)

Detailed Description

Image buffer with 16 bit color depth, used as canvas for multiple 8-bit images

See also:
RPG::Screen::canvas
RPG::Image

Member Function Documentation

static unsigned int RPG::Canvas::convert16To24Bit ( unsigned short  pixel16) [inline, static]

Converts a 16-bit pixel value to 24 bit.

Parameters:
pixel1616-bit pixel value (RRRRRGGGGGGBBBBB)
Returns:
24-bit pixel value (00000000BBBBBBBBGGGGGGGGRRRRRRRR)
static unsigned int RPG::Canvas::convert16To32Bit ( unsigned short  pixel16) [inline, static]

Converts a 16-bit pixel value to 32 bit with 100% opacity.

Parameters:
pixel1616-bit pixel value (RRRRRGGGGGGBBBBB)
Returns:
32-bit pixel value (11111111BBBBBBBBGGGGGGGGRRRRRRRR)
static unsigned short RPG::Canvas::convert24To16Bit ( unsigned int  pixel24) [inline, static]

Converts a 24-bit pixel value to 16 bit.

Parameters:
pixel2424-bit pixel value (00000000BBBBBBBBGGGGGGGGRRRRRRRR)
Returns:
16-bit pixel value (RRRRRGGGGGGBBBBB)
static unsigned short RPG::Canvas::convert32To16Bit ( unsigned int  pixel32,
unsigned short  prevPixel16 
) [inline, static]

Converts a 32-bit pixel value to 16 bit by combining it with an existing pixel.

The result is the 16-bit pixel value which is the result of drawing the pixel32 "on top" of the prevPixel16.

Parameters:
pixel3232-bit pixel value (AAAAAAAABBBBBBBBGGGGGGGGRRRRRRRR)
prevPixel1616-bit pixel value to use as basis for the alpha channel
Returns:
16-bit pixel value (RRRRRGGGGGGBBBBB)
void RPG::Canvas::draw ( int  x,
int  y,
RPG::Image image,
int  srcX = 0,
int  srcY = 0,
int  srcWidth = -1,
int  srcHeight = -1 
)

Draws an RPG::Image or a part of it onto the canvas.

This function will draw a certain part of an RPG::Image onto the canvas. You can omit the last four parameters to draw the whole image.

The image's brightness will automatically be adjusted to match the canvas brightness. To avoid this, you can save the canvas brightness, set it to 100, draw the image and then restore the original brightness of the canvas.

Parameters:
xX coordinate to draw to (upper-left origin)
yY coordinate to draw to (upper-left origin)
imageImage to draw
srcXX coordinate of the area to use from the source image
srcYY coordinate of the area to use from the source image
srcWidthWidth of the area to draw (defaults to the whole image)
srcHeightHeight of the area to draw (defaults to the whole image)
Warning:
This function is quite slow, especially if you draw an image which uses a mask color or an alpha value different from 255. Please also see the Optimization guidelines!
See also:
RPG::Image::draw
RPG::Canvas::drawStretched
RPG::Canvas::drawCenteredZoomed
void RPG::Canvas::drawCenteredZoomed ( int  x,
int  y,
double  zoomX,
double  zoomY,
RPG::Image image,
int  srcX = 0,
int  srcY = 0,
int  srcWidth = -1,
int  srcHeight = -1 
)

Draws an RPG::Image or a part of it onto the canvas, centered to a certain point, and zooms it as specified.

This function will draw a certain part of an RPG::Image onto the canvas. You can omit the last four parameters to draw the whole image. You can specify horizontal and vertical magnification, and the image's center.

The image's brightness will automatically be adjusted to match the canvas brightness. To avoid this, you can save the canvas brightness, set it to 100, draw the image and then restore the original brightness of the canvas.

Parameters:
xX coordinate to draw to (center origin)
yY coordinate to draw to (center origin)
zoomXHorizontal magnification (1.0 is normal)
zoomYVertical magnification (1.0 is normal)
imageImage to draw
srcXX coordinate of the area to use from the source image
srcYY coordinate of the area to use from the source image
srcWidthWidth of the area to draw (defaults to the whole image)
srcHeightHeight of the area to draw (defaults to the whole image)
Warning:
This function is quite slow, especially if you draw an image which uses a mask color or an alpha value different from 255 or zoomX and/or zoomY values different from 1.0. Please also see the Optimization guidelines!
See also:
RPG::Canvas::drawStretched
RPG::Canvas::draw
void RPG::Canvas::drawStretched ( int  x,
int  y,
int  width,
int  height,
RPG::Image image,
int  srcX = 0,
int  srcY = 0,
int  srcWidth = -1,
int  srcHeight = -1 
)

Draws an RPG::Image or a part of it onto the canvas, stretched to a certain rectangle.

This function will draw a certain part of an RPG::Image onto the canvas. You can omit the last four parameters to draw the whole image. The image (or the part of it) will be stretched so it fits into the given rectangle

The image's brightness will automatically be adjusted to match the canvas brightness. To avoid this, you can save the canvas brightness, set it to 100, draw the image and then restore the original brightness of the canvas.

Parameters:
xX coordinate to draw to (upper-left origin)
yY coordinate to draw to (upper-left origin)
widthTarget width of the image after stretching
heightTarget height of the image after stretching
imageImage to draw
srcXX coordinate of the area to use from the source image
srcYY coordinate of the area to use from the source image
srcWidthWidth of the area to draw (defaults to the whole image)
srcHeightHeight of the area to draw (defaults to the whole image)
Warning:
This function is quite slow, especially if you draw an image which uses a mask color or an alpha value different from 255. Please also see the Optimization guidelines!
See also:
RPG::Canvas::drawCenteredZoomed
RPG::Canvas::draw
unsigned short* RPG::Canvas::getScanline ( int  y)

Returns a pointer to a row of pixel data.

Parameters:
yY coordinate
Returns:
Pointer to the first pixel of the row
Note:
If you loop through rows, it is way faster to use getScanline(0) once and then always add lineSize to get to the next row instead of calling getScanline for every row.

Returns the height of the bitmap.

unsigned short& RPG::Canvas::pixel ( int  x,
int  y 
)

Returns a reference to a pixel.

Parameters:
xX coordinate
yY coordinate
Returns:
Reference to the pixel

Returns the width of the bitmap.


Member Data Documentation

Underlying 16-bit bitmap.

Brightness of the screen (see details)

Supported values are from 0 (completely black) to 200 (completely white). 100 is the normal value. This value is changed during "fading" screen transitions.

Note:
Values higher than 200 will cause the colors to go crazy. Of course, this can also be used as an intentional effect, for example the value 204 will only use the colors blue, white and black.

Number of bytes you have to add to a pixel address to get the address of the pixel in the same column of the next pixel row (see details)

Normally, this number is negative because bitmaps are stored from bottom to top.

 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator