Skip to content

Instantly share code, notes, and snippets.

View Cyberax's full-sized avatar

Alex Besogonov Cyberax

View GitHub Profile
int generate_indexed_something(size_t BufPixels, xxx ResultArray, xxx pixels, int_t pixlen)
{
PyObject * BufString = 0;
PyObject * Result = 0;
/* extend ResultArray by a bunch of converted pixels at a time */
if (BufPixels % 4 != 0)
{
/* fill out unused part of byte with zeroes--actually shouldn't occur */
PixBuf[BufPixels / 4] &= ~(0xff << BufPixels % 4 * 2);
static void ParseColorsTuple
(
PyObject * ColorTuple,
uint32_t * colors /* array of 4 elements */
)
/* parses ColorTuple as a tuple of 4 elements, each in turn being a tuple of
4 integers (r, g, b, a) each in the range [0 .. 255]. Puts the result as
Cairo-format pixel values into colors. */
{
PyObject * TheColors[4] = {0, 0, 0, 0};