Welcome to the Creatures Wiki! Log in and join the community.
555/565
Jump to navigation
Jump to search
Summary
555 and 565 are used to describe different allocations of bits inside a 16-bit integer representing a pixel, as used in Creatures sprite files such as BLK and C16.
Technical Information
In 555 format, the bits are allocated as follows:
0123 4567 0123 4567 -rrr rr-- ---- ---- (bitmask: 0x7C00) ---- --gg ggg- ---- (bitmask: 0x3E0) ---- ---- ---b bbbb (bitmask: 0x1F)
In 565 format, the bits are allocated as follows:
0123 4567 0123 4567 rrrr r--- ---- ---- (bitmask: 0xF800) ---- -ggg ggg- ---- (bitmask: 0x7E0) ---- ---- ---b bbbb (bitmask: 0x1F)
The following macros can be used in C or C++ to decode these values to normal 24-bit format:
/* Decoding macros by bd_ aka bdonlan. I release these into the public domain. */ #define RGB(r, g, b) ((r) << 16 | (g) << 8 | (b)) #define DECODE_555(v) \ (RGB( \ ((uint32_t)(v) & 0x7c00) >> 7, \ ((uint32_t)(v) & 0x03e0) >> 2, \ ((uint32_t)(v) & 0x001f) << 3 \ )) #define DECODE_565(v) \ (RGB( \ ((uint32_t)(v) & 0xf800) >> 8 , \ ((uint32_t)(v) & 0x07e0) >> 3 , \ ((uint32_t)(v) & 0x001f) << 3 \ ))