![]() |
GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
Helper macros to get and set bits given offset and length. More...
Go to the source code of this file.
Macros | |
#define | GP_GET_BITS(offset, len, val) |
Helper macros to read parts of words. | |
#define | GP_GET_BITS4_LE(offset, len, buf) |
Little endian align-safe get bits. | |
#define | GP_GET_BITS4_BE(offset, len, buf) |
Big endian align-safe get bits. | |
#define | GP_GET_BITS3_LE(offset, len, buf) |
Little endian align-safe get bits. | |
#define | GP_GET_BITS3_BE(offset, len, buf) |
Big endian align-safe get bits. | |
#define | GP_GET_BITS2_LE(offset, len, buf) |
Little endian align-safe get bits. | |
#define | GP_GET_BITS2_BE(offset, len, buf) |
Big endian align-safe get bits. | |
#define | GP_GET_BITS1(offset, len, buf) |
Align-safe get bits. | |
#define | GP_CLEAR_BITS(offset, len, dest) |
Clear len bits at offset in dest. | |
#define | GP_SET_BITS(offset, len, dest, val) |
Set len bits at offset in dest from val. | |
#define | GP_SET_BITS1(offset, len, dest, val) |
Align-safe set bits. | |
#define | GP_SET_BITS2_LE(offset, len, dest, val) |
Little endian align-safe set bits. | |
#define | GP_SET_BITS2_BE(offset, len, dest, val) |
Big endian align-safe set bits. | |
#define | GP_SET_BITS3_LE(offset, len, dest, val) |
Little endian align-safe set bits. | |
#define | GP_SET_BITS3_BE(offset, len, dest, val) |
Big endian align-safe set bits. | |
#define | GP_SET_BITS4_LE(offset, len, dest, val) |
Little endian align-safe set bits. | |
#define | GP_SET_BITS4_BE(offset, len, dest, val) |
Big endian align-safe set bits. | |
Helper macros to get and set bits given offset and length.
The GP_GET_BITS() and GP_SET_BITS() works ONLY on aligned data types. Which means that you can only pass value that is suitably aligned for it's type, for example passing an 32 bit integer is OK, passing a char buffer casted to 32 bit integer is not (unless you made sure that the start address is multiple of 4). These macros also work with the machine endianity if pixels are packed in foreign endianity, the data has to be swapped properly at the input or output.
The align-safe variants first gets the value from a buffer, byte by byte and then uses the GP_GET_BITS() or GP_SET_BITS(). The number in their name tells how much bytes are touched and the endianity suffix describes the endianity these macros work with.
Definition in file gp_get_set_bits.h.
#define GP_CLEAR_BITS | ( | offset, | |
len, | |||
dest ) |
Clear len bits at offset in dest.
Operates on 8, 16, and 32 bit values, depending on the type of dest, which has to be unsigned.
offset | Number of bits to keep on the left side. |
len | Number of bits to clear. |
dest | A value to operate on. |
Definition at line 175 of file gp_get_set_bits.h.
#define GP_GET_BITS | ( | offset, | |
len, | |||
val ) |
Helper macros to read parts of words.
offset | How much to shift the val left. |
len | How much bits from val should we keep. |
val | A value to be shifted and masked. |
Definition at line 36 of file gp_get_set_bits.h.
#define GP_GET_BITS1 | ( | offset, | |
len, | |||
buf ) |
Align-safe get bits.
Reads byte then shifts and masks it.
offset | Number of bits to shift to left. |
len | A number of bits to return. |
buf | A pointer to a starting byte of the buffer. |
Definition at line 158 of file gp_get_set_bits.h.
Referenced by gp_getpixel_raw_1BPP_DB(), gp_getpixel_raw_1BPP_UB(), gp_getpixel_raw_2BPP_DB(), gp_getpixel_raw_2BPP_UB(), gp_getpixel_raw_4BPP_DB(), and gp_getpixel_raw_4BPP_UB().
#define GP_GET_BITS2_BE | ( | offset, | |
len, | |||
buf ) |
Big endian align-safe get bits.
Reads two bytes byte by byte, composes then shifts and masks them.
offset | Number of bits to shift to left. |
len | A number of bits to return. |
buf | A pointer to a starting byte of the buffer. |
Definition at line 141 of file gp_get_set_bits.h.
#define GP_GET_BITS2_LE | ( | offset, | |
len, | |||
buf ) |
Little endian align-safe get bits.
Reads two bytes byte by byte, composes then shifts and masks them.
offset | Number of bits to shift to left. |
len | A number of bits to return. |
buf | A pointer to a starting byte of the buffer. |
Definition at line 124 of file gp_get_set_bits.h.
#define GP_GET_BITS3_BE | ( | offset, | |
len, | |||
buf ) |
Big endian align-safe get bits.
Reads three bytes byte by byte, composes then shifts and masks them.
offset | Number of bits to shift to left. |
len | A number of bits to return. |
buf | A pointer to a starting byte of the buffer. |
Definition at line 106 of file gp_get_set_bits.h.
#define GP_GET_BITS3_LE | ( | offset, | |
len, | |||
buf ) |
Little endian align-safe get bits.
Reads three bytes byte by byte, composes then shifts and masks them.
offset | Number of bits to shift to left. |
len | A number of bits to return. |
buf | A pointer to a starting byte of the buffer. |
Definition at line 88 of file gp_get_set_bits.h.
Referenced by gp_getpixel_raw_18BPP_DB(), and gp_getpixel_raw_24BPP().
#define GP_GET_BITS4_BE | ( | offset, | |
len, | |||
buf ) |
Big endian align-safe get bits.
Reads four bytes byte by byte, composes then shifts and masks them.
offset | Number of bits to shift to left. |
len | A number of bits to return. |
buf | A pointer to a starting byte of the buffer. |
Definition at line 69 of file gp_get_set_bits.h.
#define GP_GET_BITS4_LE | ( | offset, | |
len, | |||
buf ) |
Little endian align-safe get bits.
Reads four bytes byte by byte, composes then shifts and masks them.
offset | Number of bits to shift to left. |
len | A number of bits to return. |
buf | A pointer to a starting byte of the buffer. |
Definition at line 50 of file gp_get_set_bits.h.
#define GP_SET_BITS | ( | offset, | |
len, | |||
dest, | |||
val ) |
Set len bits at offset in dest from val.
Operates on 8, 16, and 32 bit values, depending on the type of dest, which has to be unsigned.
offset | Number of bits to keep on the left side. |
len | Number of bits to clear. |
dest | A value to operate on. |
val | A value to written to dest. |
Definition at line 189 of file gp_get_set_bits.h.
#define GP_SET_BITS1 | ( | offset, | |
len, | |||
dest, | |||
val ) |
Align-safe set bits.
Gets a single byte from dest, combines it with len bytes from value at offset and writes it back.
offset | An offset in the byte. |
len | A number of bits to write. |
dest | A buffer to write the data to. |
val | A value to be written. |
Definition at line 205 of file gp_get_set_bits.h.
Referenced by gp_putpixel_raw_1BPP_DB(), gp_putpixel_raw_1BPP_UB(), gp_putpixel_raw_2BPP_DB(), gp_putpixel_raw_2BPP_UB(), gp_putpixel_raw_4BPP_DB(), and gp_putpixel_raw_4BPP_UB().
#define GP_SET_BITS2_BE | ( | offset, | |
len, | |||
dest, | |||
val ) |
Big endian align-safe set bits.
Gets two bytes from dest, combines them with len bytes from value at offset and writes it back.
offset | An offset in the byte. |
len | A number of bits to write. |
dest | A buffer to write the data to. |
val | A value to be written. |
Definition at line 244 of file gp_get_set_bits.h.
#define GP_SET_BITS2_LE | ( | offset, | |
len, | |||
dest, | |||
val ) |
Little endian align-safe set bits.
Gets two bytes from dest, combines them with len bytes from value at offset and writes it back.
offset | An offset in the byte. |
len | A number of bits to write. |
dest | A buffer to write the data to. |
val | A value to be written. |
Definition at line 222 of file gp_get_set_bits.h.
#define GP_SET_BITS3_BE | ( | offset, | |
len, | |||
dest, | |||
val ) |
Big endian align-safe set bits.
Gets three bytes from dest, combines them with len bytes from value at offset and writes it back.
offset | An offset in the byte. |
len | A number of bits to write. |
dest | A buffer to write the data to. |
val | A value to be written. |
Definition at line 290 of file gp_get_set_bits.h.
#define GP_SET_BITS3_LE | ( | offset, | |
len, | |||
dest, | |||
val ) |
Little endian align-safe set bits.
Gets three bytes from dest, combines them with len bytes from value at offset and writes it back.
offset | An offset in the byte. |
len | A number of bits to write. |
dest | A buffer to write the data to. |
val | A value to be written. |
Definition at line 266 of file gp_get_set_bits.h.
Referenced by gp_putpixel_raw_18BPP_DB(), and gp_putpixel_raw_24BPP().
#define GP_SET_BITS4_BE | ( | offset, | |
len, | |||
dest, | |||
val ) |
Big endian align-safe set bits.
Gets four bytes from dest, combines them with len bytes from value at offset and writes it back.
offset | An offset in the byte. |
len | A number of bits to write. |
dest | A buffer to write the data to. |
val | A value to be written. |
Definition at line 340 of file gp_get_set_bits.h.
#define GP_SET_BITS4_LE | ( | offset, | |
len, | |||
dest, | |||
val ) |
Little endian align-safe set bits.
Gets four bytes from dest, combines them with len bytes from value at offset and writes it back.
offset | An offset in the byte. |
len | A number of bits to write. |
dest | A buffer to write the data to. |
val | A value to be written. |
Definition at line 314 of file gp_get_set_bits.h.