/* * The Npic library * * Copyright (C) 2003 Edouard Thiel * * This library is free software under the terms of the * GNU Lesser General Public License (LGPL) version 2.1. */ /* * pixels.h - 31/12/2003 * * pixel types */ #ifndef NPIC__PIXELS_H #define NPIC__PIXELS_H /* Check if char is 8-bit, short is 16-bit and long is 32-bit, or find equivalent types, using macros defined in limits.h */ #if UCHAR_MAX == 255 typedef signed char Npic_sint8; typedef unsigned char Npic_uint8; #else #error char is not 8-bit in this environment #endif #if USHRT_MAX == 65535 typedef signed short Npic_sint16; typedef unsigned short Npic_uint16; #else #error short is not 16-bit in this environment #endif #if ULONG_MAX == 4294967295UL typedef signed long Npic_sint32; typedef unsigned long Npic_uint32; # define NPIC_PL "ld" #elif UINT_MAX == 4294967295U typedef signed int Npic_sint32; typedef unsigned int Npic_uint32; # define NPIC_PL "d" #else #error long is not 32-bit in this environment #endif /* From bits/byteswap.h */ #define NPIC_BSWAP16(x) \ ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)) #define NPIC_BSWAP32(x) \ ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) #define NPIC_BSWAP64(x) \ ((((x) & 0xff00000000000000ull) >> 56) | \ (((x) & 0x00ff000000000000ull) >> 40) | \ (((x) & 0x0000ff0000000000ull) >> 24) | \ (((x) & 0x000000ff00000000ull) >> 8) | \ (((x) & 0x00000000ff000000ull) << 8) | \ (((x) & 0x0000000000ff0000ull) << 24) | \ (((x) & 0x000000000000ff00ull) << 40) | \ (((x) & 0x00000000000000ffull) << 56)) /* * Pixel type definitions */ typedef Npic_uint8 Npic_c; /* char */ typedef Npic_sint16 Npic_s; /* short */ typedef Npic_sint32 Npic_l; /* long */ typedef double Npic_d; /* floating number */ /* Quadri and alternatives */ typedef struct { Npic_uint16 a, b, c, d ; } Npic_q; typedef struct { Npic_uint16 r, g, b, a ; } Npic_rgba; typedef struct { Npic_uint16 c, m, y, k ; } Npic_cmyk; typedef struct { Npic_uint16 h, s, v, a ; } Npic_hsva; /* Pixel nature */ enum { NPIC_NONE = 0X4251, NPIC_C, NPIC_L, NPIC_D, NPIC_Q }; /* For backward compatibility >= 0.21 */ #define NPIC_PRINTF_L NPIC_PL #endif /* NPIC__PIXELS_H */