Represents an image resource loaded from a file, with 2 bits per pixel (4 colors).
More...
|
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...
|
|
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.