Image buffer with 16 bit color depth, used as canvas for multiple 8-bit images
More...
#include <Canvas.h>
|
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 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.
|
|
|
DBitmap * | bitmap |
| 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)
|
|
Image buffer with 16 bit color depth, used as canvas for multiple 8-bit images
- See also
- RPG::Screen::canvas
-
RPG::Image
◆ convert16To24Bit()
static unsigned int RPG::Canvas::convert16To24Bit |
( |
unsigned short | pixel16 | ) |
|
|
inlinestatic |
Converts a 16-bit pixel value to 24 bit.
- Parameters
-
pixel16 | 16-bit pixel value (RRRRRGGGGGGBBBBB ) |
- Returns
- 24-bit pixel value (
00000000BBBBBBBBGGGGGGGGRRRRRRRR
)
◆ convert16To32Bit()
static unsigned int RPG::Canvas::convert16To32Bit |
( |
unsigned short | pixel16 | ) |
|
|
inlinestatic |
Converts a 16-bit pixel value to 32 bit with 100% opacity.
- Parameters
-
pixel16 | 16-bit pixel value (RRRRRGGGGGGBBBBB ) |
- Returns
- 32-bit pixel value (
11111111BBBBBBBBGGGGGGGGRRRRRRRR
)
◆ convert24To16Bit()
static unsigned short RPG::Canvas::convert24To16Bit |
( |
unsigned int | pixel24 | ) |
|
|
inlinestatic |
Converts a 24-bit pixel value to 16 bit.
- Parameters
-
pixel24 | 24-bit pixel value (00000000BBBBBBBBGGGGGGGGRRRRRRRR ) |
- Returns
- 16-bit pixel value (
RRRRRGGGGGGBBBBB
)
◆ convert32To16Bit()
static unsigned short RPG::Canvas::convert32To16Bit |
( |
unsigned int | pixel32, |
|
|
unsigned short | prevPixel16 ) |
|
inlinestatic |
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
-
pixel32 | 32-bit pixel value (AAAAAAAABBBBBBBBGGGGGGGGRRRRRRRR ) |
prevPixel16 | 16-bit pixel value to use as basis for the alpha channel |
- Returns
- 16-bit pixel value (
RRRRRGGGGGGBBBBB
)
◆ draw()
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
-
x | X coordinate to draw to (upper-left origin) |
y | Y coordinate to draw to (upper-left origin) |
image | Image to draw |
srcX | X coordinate of the area to use from the source image |
srcY | Y coordinate of the area to use from the source image |
srcWidth | Width of the area to draw (defaults to the whole image) |
srcHeight | Height 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
◆ 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
-
x | X coordinate to draw to (center origin) |
y | Y coordinate to draw to (center origin) |
zoomX | Horizontal magnification (1.0 is normal) |
zoomY | Vertical magnification (1.0 is normal) |
image | Image to draw |
srcX | X coordinate of the area to use from the source image |
srcY | Y coordinate of the area to use from the source image |
srcWidth | Width of the area to draw (defaults to the whole image) |
srcHeight | Height 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
◆ drawStretched()
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
-
x | X coordinate to draw to (upper-left origin) |
y | Y coordinate to draw to (upper-left origin) |
width | Target width of the image after stretching |
height | Target height of the image after stretching |
image | Image to draw |
srcX | X coordinate of the area to use from the source image |
srcY | Y coordinate of the area to use from the source image |
srcWidth | Width of the area to draw (defaults to the whole image) |
srcHeight | Height 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
◆ getScanline()
unsigned short * RPG::Canvas::getScanline |
( |
int | y | ) |
|
Returns a pointer to a row of pixel data.
- Parameters
-
- 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.
◆ pixel()
unsigned short & RPG::Canvas::pixel |
( |
int | x, |
|
|
int | y ) |
Returns a reference to a pixel.
- Parameters
-
x | X coordinate |
y | Y coordinate |
- Returns
- Reference to the pixel
◆ brightness
int RPG::Canvas::brightness |
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.
◆ lineSize
int RPG::Canvas::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)
Normally, this number is negative because bitmaps are stored from bottom to top.
The documentation for this class was generated from the following file: