Arcade
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
GameAPI.BudgetBoy.RawImage Class Reference

Represents an image resource loaded from a file, with 2 bits per pixel (4 colors). More...

Inheritance diagram for GameAPI.BudgetBoy.RawImage:
GameAPI.BudgetBoy.Image

Public Member Functions

byte GetPixel (int x, int y)
 Retrieves the value of a pixel at the given coordinate in this image. The value will be a number from 0 to 3, representing the index of which of the four colours in a Swatch would be drawn for that pixel. The bottom left of the image has coodinates (0, 0), and the top right has coordinates (Width, Height). More...
 
byte GetPixel (Vector2I pos)
 Retrieves the value of a pixel at the given coordinate in this image. The value will be a number from 0 to 3, representing the index of which of the four colours in a Swatch would be drawn for that pixel. The bottom left of the image has coodinates (0, 0), and the top right has coordinates (Width, Height). More...
 
IEnumerable< byte > GetPixels (int x, int y, int w, int h)
 Retrieves a sequence containing the values of a rectangle of pixels in this image. Values are returned row by row, from the smallest X and Y first. Each value will be a number from 0 to 3, representing the index of which of the four colours in a Swatch would be drawn for that pixel. The bottom left of the image has coodinates (0, 0), and the top right has coordinates (Width, Height). More...
 
IEnumerable< byte > GetPixels (RectI rect)
 Retrieves a sequence containing the values of a rectangle of pixels in this image. Values are returned row by row, from the smallest X and Y first. Each value will be a number from 0 to 3, representing the index of which of the four colours in a Swatch would be drawn for that pixel. The bottom left of the image has coodinates (0, 0), and the top right has coordinates (Width, Height). More...
 

Additional Inherited Members

- Properties inherited from GameAPI.BudgetBoy.Image
Vector2I Size [get]
 Returns the width/height of the image. More...
 
int Width [get]
 Horizontal resolution in pixels. More...
 
int Height [get]
 Vertical resolution in pixels. More...
 
int Area [get]
 Product of the width and height. More...
 

Detailed Description

Represents an image resource loaded from a file, with 2 bits per pixel (4 colors).

Image Resource Formats

RawImage resources are loaded from PNG files, which may be 24-bit, 32-bit or 8-bit with a palette. Each pixel in the image is assigned an index from 0 to 3 which is used to find which color to draw from a 4 color swatch. The rules for assigning indices to each pixel are as follows:

24-bit PNG / Grayscale PNG

Each pixel's color is compared to four key colors: 0x000000, 0x555555, 0xaaaaaa and 0xffffff. If the pixel is closest to the first color it is assigned index 0, if it is closest to the second it is assigned index 1, and so on.

32-bit PNG / Grayscale + Alpha PNG

The same rule applies as with 24-bit PNGs for each pixel with an alpha value greater than or equal to 50%, but all pixels with alpha below 50% are assigned index 3 which is usually reserved for transparency.

8-bit PNG

As this format already includes indices for each pixel, these indices are used straight from the file. This lets you use any colors you wish when making the image, but care should be taken to ensure the palette stored within the PNG uses only 4 colors and in the order you intend them to be in.

Member Function Documentation

byte GameAPI.BudgetBoy.RawImage.GetPixel ( int  x,
int  y 
)
inline

Retrieves the value of a pixel at the given coordinate in this image. The value will be a number from 0 to 3, representing the index of which of the four colours in a Swatch would be drawn for that pixel. The bottom left of the image has coodinates (0, 0), and the top right has coordinates (Width, Height).

Parameters
xHorizontal coordinate of the pixel.
yVertical coordinate of the pixel.
Returns
A byte with a value between 0 and 3.
byte GameAPI.BudgetBoy.RawImage.GetPixel ( Vector2I  pos)
inline

Retrieves the value of a pixel at the given coordinate in this image. The value will be a number from 0 to 3, representing the index of which of the four colours in a Swatch would be drawn for that pixel. The bottom left of the image has coodinates (0, 0), and the top right has coordinates (Width, Height).

Parameters
posCoordinate of the pixel.
Returns
A byte with a value between 0 and 3.
IEnumerable<byte> GameAPI.BudgetBoy.RawImage.GetPixels ( int  x,
int  y,
int  w,
int  h 
)
inline

Retrieves a sequence containing the values of a rectangle of pixels in this image. Values are returned row by row, from the smallest X and Y first. Each value will be a number from 0 to 3, representing the index of which of the four colours in a Swatch would be drawn for that pixel. The bottom left of the image has coodinates (0, 0), and the top right has coordinates (Width, Height).

Parameters
xLeft-most horizontal coordinate of the rectangle.
yBottom-most vertical coordinate of the rectangle.
wNumber of columns of pixels to retrieve.
hNumber of rows of pixels to retrieve.
Returns
A sequence of bytes with values between 0 and 3.
IEnumerable<byte> GameAPI.BudgetBoy.RawImage.GetPixels ( RectI  rect)
inline

Retrieves a sequence containing the values of a rectangle of pixels in this image. Values are returned row by row, from the smallest X and Y first. Each value will be a number from 0 to 3, representing the index of which of the four colours in a Swatch would be drawn for that pixel. The bottom left of the image has coodinates (0, 0), and the top right has coordinates (Width, Height).

Parameters
rectRectangle describing the region to retrieve.
Returns
A sequence of bytes with values between 0 and 3.