Welcome to the Creatures Wiki! Log in and join the community.

Difference between revisions of "555/565"

From Creatures Wiki
Jump to navigation Jump to search
(move shared information here from BLK files)
 
m (move link)
Line 1: Line 1:
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 files|BLK]] and [[C16 Files|C16]].
+
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 files|BLK]] and [[C16 files|C16]].
  
 
In 555 format, the bits are allocated as follows:
 
In 555 format, the bits are allocated as follows:

Revision as of 00:49, 16 February 2005

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.

In 555 format, the bits are allocated as follows:

 0123 4567 0123 4567
 -rrr rr-- ---- ----
 ---- --gg ggg- ----
 ---- ---- ---b bbbb

In 565 format, the bits are allocated as follows:

 0123 4567 0123 4567
 rrrr r--- ---- ----
 ---- -ggg ggg- ----
 ---- ---- ---b bbbb

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)           \
	(qRgb(                      \
		  ((uint32_t)(v) & 0x7800) >> 7,  \
		  ((uint32_t)(v) & 0x03e0) >> 2,  \
		  ((uint32_t)(v) & 0x001f) << 3  \
		 ))

#define DECODE_565(v)           \
	(qRgb(                      \
		  ((uint32_t)(v) & 0xf800) >> 8 , \
		  ((uint32_t)(v) & 0x07e0) >> 3 , \
		  ((uint32_t)(v) & 0x001f) << 3   \
		 ))