DynRPG v0.32 Unofficial
Plugin SDK
|
Used for image buffers (8 bit) More...
#include <Image.h>
Public Member Functions | |
void | applyPalette () |
Applies palette changes. | |
unsigned char & | pixel (int x, int y) |
Returns a reference to a certain pixel. Each pixel contains the palette ID (so one could do image->palette[image->pixel(x,y)] to get the color of a pixel at a certain x/y coordinate in GGBBRR order) | |
void | free () |
Frees the image and sets its size to zero. | |
void | init (int newWidth, int newHeight) |
Clears the image and initializes it to a new size. | |
void | setPalette (int *newPalette) |
Copies a palette to the image and applies it. | |
void | copy (Image *image) |
Copies an RPG::Image with all its attributes to another. | |
void | loadFromFile (std::string filename, bool throwErrors=true, bool autoResize=true) |
Loads an image from a file. | |
void | draw (int x, int y, unsigned char *newPixels, int srcWidth, int srcHeight, int srcLineWidth, int maskColor=0) |
Copies pixels into the image. | |
void | draw (int x, int y, Image *image, int srcX=0, int srcY=0, int srcWidth=-1, int srcHeight=-1, int maskColor=0) |
Draws another image (or a part of it) onto the image. | |
void | clear () |
Clears the image without resizing or freeing it. | |
void | setSystemPalette () |
Copies the palette from the system (necessary for drawText) | |
void | drawText (int x, int y, std::string text, int color) |
Broken as of v 0.20. Use RPG::Image::drawString instead as it is using the same rm2k3 function, but references it in memory correctly. | |
void | drawString (int x, int y, std::string text, int color) |
Draws text onto the image. | |
Static Public Member Functions | |
static Image * | create () |
Creates an empty image. | |
static Image * | create (int newWidth, int newHeight) |
Creates an image with a certain width and height. | |
static Image * | create (Image *templateImage) |
Creates a copy of an image. | |
static void | destroy (Image *&image) |
Destroys an image. | |
Public Attributes | |
unsigned char * | pixels |
Pointer to direct pixel data (stored from top to bottom). Each pixel contains the palette ID (so one could reference it as image->palette[image->pixels[i]] to get the color of a pixel at the location in GGBBRR order) | |
int | palette [256] |
Palette array (24 bit) | |
short | appliedPalette [256] |
Processed palette array (16 bit - do not use directly) | |
int | width |
Width of the image. | |
int | height |
Height of the image. | |
bool | useMaskColor |
If true , color 0 will be used as transparent color. | |
int | alpha |
Alpha value (0 is invisible, 255 is fully visible) | |
bool | autoResize |
If true , the image will automatically resize when loaded from a file. | |
ColorControl * | colorControl1 |
First color effect. | |
ColorControl * | colorControl2 |
Second color effect. | |
int | appliedPaletteBrightness |
Brightness for which the appliedPalette was calculated. | |
Used for image buffers (8 bit)
This class is the only class of which instances may be created by the plugin developer, using the create and destroy methods. It is used for all kinds of images (8 bit). There are two palette arrays: The palette array is used to store the actual 24-bit colors, and the appliedPalette array is used to store special calculated values corresponding to the current screen brightness. It uses 16-bit colors. The applyPalette method is used to recalculate the appliedPalette values. The appliedPaletteBrightness member stores the brightness value for which the appliedPalette was created. If it doesn't equal to the current screen brightness, the RPG Maker will automatically call applyPalette when the image is drawn.
I know that this is overkill and it would have been easier to draw the images to the screen first and then reduce the brightness of the pixels on the screen, but the RPG Maker decided to do it this way.
Copies an RPG::Image with all its attributes to another.
Instead of *image2 = *image1;
, you must use image2->copy(image1);
.
image | The image to copy (source) |
Creates an empty image.
Creates a copy of an image.
templateImage | Image to copy |
Creates an image with a certain width and height.
newWidth | Width of the new image |
newHeight | Height of the new image |
void RPG::Image::draw | ( | int | x, |
int | y, | ||
Image * | image, | ||
int | srcX = 0, | ||
int | srcY = 0, | ||
int | srcWidth = -1, | ||
int | srcHeight = -1, | ||
int | maskColor = 0 ) |
Draws another image (or a part of it) onto the image.
This part can be used to blit another image, or a certain part of it. Please keep in mind that this will produce strange results if the other image has a different palette.
x | Upper-left X coordinate at the destination image |
y | Upper-left Y coordinate at the destination image |
image | Image to draw |
srcX | Upper-left X coordinate at the source image |
srcY | Upper-left Y coordinate at the source image |
srcWidth | Width of the area to copy (defaults to the whole image) |
srcHeight | Height of the area to copy (defaults to the whole image) |
maskColor | Color which should be transparent (can also be RPG::MASK_NONE) |
void RPG::Image::draw | ( | int | x, |
int | y, | ||
unsigned char * | newPixels, | ||
int | srcWidth, | ||
int | srcHeight, | ||
int | srcLineWidth, | ||
int | maskColor = 0 ) |
Copies pixels into the image.
x | X coordinate to start drawing to |
y | Y coordinate to start drawing to |
newPixels | Pointer to the pixel data to copy |
srcWidth | Width of area to copy |
srcHeight | Height of the area to copy |
srcLineWidth | Width of a pixel row in the source image |
maskColor | Color which should be transparent (can also be RPG::MASK_NONE) |
Draws text onto the image.
This method will draw text onto the image, using the current system font and system graphic. Glyphs (like $A
) work too.
x | Upper-left X position |
y | Upper-left Y position |
text | Text to draw |
color | Text color to use (0 to 19 ) |
Broken as of v 0.20. Use RPG::Image::drawString instead as it is using the same rm2k3 function, but references it in memory correctly.
Clears the image and initializes it to a new size.
newWidth | New image width |
newHeight | New image height |
void RPG::Image::loadFromFile | ( | std::string | filename, |
bool | throwErrors = true, | ||
bool | autoResize = true ) |
Loads an image from a file.
This function will load an image from a BMP, PNG or XYZ file.
filename | Path and filename of the file to load, including folder name and file extension. |
throwErrors | If true , an error will be shown when the image doesn't exist, otherwise the image will just be empty. |
autoResize | If true , the image will automatically resize to the size of the image in the file. |
Returns a reference to a certain pixel. Each pixel contains the palette ID (so one could do image->palette[image->pixel(x,y)] to get the color of a pixel at a certain x/y coordinate in GGBBRR order)
x | X coordinate of the pixel |
y | Y coordinate of the pixel |
Copies a palette to the image and applies it.
newPalette | Pointer to the palette array to copy |
void RPG::Image::setSystemPalette | ( | ) |
Copies the palette from the system (necessary for drawText)