|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef _PIXEL_H_
|
|
Toshihiro Shimizu |
890ddd |
#define _PIXEL_H_
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "machine.h"
|
|
Toshihiro Shimizu |
890ddd |
//#include "toonz.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tnztypes.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TNZ_MACHINE_CHANNEL_ORDER_BGRM
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
typedef struct _LPIXEL { unsigned char b, g, r, m; } LPIXEL;
|
|
Shinya Kitaoka |
120a6e |
typedef struct _SPIXEL { unsigned short b, g, r, m; } SPIXEL;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if TNZ_LITTLE_ENDIAN
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_RGBM_MASK 0xffffffff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_RGB_MASK 0x00ffffff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_M_MASK 0xff000000
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_R_MASK 0x00ff0000
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_G_MASK 0x0000ff00
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_B_MASK 0x000000ff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_M_SHIFT 24
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_R_SHIFT 16
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_G_SHIFT 8
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_B_SHIFT 0
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_RGBM_MASK 0xffffffff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_RGB_MASK 0xffffff00
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_M_MASK 0x000000ff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_R_MASK 0x0000ff00
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_G_MASK 0x00ff0000
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_B_MASK 0xff000000
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_M_SHIFT 0
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_R_SHIFT 8
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_G_SHIFT 16
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_B_SHIFT 24
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Campbell Barton |
d869b5 |
#elif defined(TNZ_MACHINE_CHANNEL_ORDER_MBGR)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
typedef struct { unsigned char m, b, g, r; } LPIXEL;
|
|
Shinya Kitaoka |
120a6e |
typedef struct { unsigned short m, b, g, r; } SPIXEL;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if TNZ_LITTLE_ENDIAN
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_RGBM_MASK 0xffffffff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_RGB_MASK 0xffffff00
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_M_MASK 0x000000ff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_R_MASK 0xff000000
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_G_MASK 0x00ff0000
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_B_MASK 0x0000ff00
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_M_SHIFT 0
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_R_SHIFT 24
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_G_SHIFT 16
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_B_SHIFT 8
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_RGBM_MASK 0xffffffff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_RGB_MASK 0x00ffffff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_M_MASK 0xff000000
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_R_MASK 0x000000ff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_G_MASK 0x0000ff00
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_B_MASK 0x00ff0000
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_M_SHIFT 24
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_R_SHIFT 0
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_G_SHIFT 8
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_B_SHIFT 16
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
|
e280ae |
#elif defined(TNZ_MACHINE_CHANNEL_ORDER_RGBM)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
typedef struct _LPIXEL { unsigned char r, g, b, m; } LPIXEL;
|
|
Shinya Kitaoka |
120a6e |
typedef struct _SPIXEL { unsigned short r, g, b, m; } SPIXEL;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if TNZ_LITTLE_ENDIAN
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_RGBM_MASK 0xffffffff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_RGB_MASK 0x00ffffff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_M_MASK 0xff000000
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_B_MASK 0x00ff0000
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_G_MASK 0x0000ff00
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_R_MASK 0x000000ff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_M_SHIFT 24
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_B_SHIFT 16
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_G_SHIFT 8
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_R_SHIFT 0
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_RGBM_MASK 0xffffffff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_RGB_MASK 0xffffff00
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_M_MASK 0x000000ff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_R_MASK 0x0000ff00
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_G_MASK 0x00ff0000
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_B_MASK 0xff000000
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_M_SHIFT 0
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_R_SHIFT 8
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_G_SHIFT 16
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_B_SHIFT 24
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
|
e280ae |
#elif defined(TNZ_MACHINE_CHANNEL_ORDER_MRGB)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
typedef struct _LPIXEL { unsigned char m, r, g, b; } LPIXEL;
|
|
Shinya Kitaoka |
120a6e |
typedef struct _SPIXEL { unsigned short m, r, g, b; } SPIXEL;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if TNZ_LITTLE_ENDIAN
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_RGBM_MASK 0xffffffff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_RGB_MASK 0xffffff00
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_B_MASK 0xff000000
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_G_MASK 0x00ff0000
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_R_MASK 0x0000ff00
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_M_MASK 0x000000ff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_B_SHIFT 24
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_G_SHIFT 16
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_R_SHIFT 8
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_M_SHIFT 0
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_RGBM_MASK 0xffffffff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_RGB_MASK 0x00ffffff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_B_MASK 0x000000ff
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_G_MASK 0x0000ff00
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_R_MASK 0x00ff0000
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_M_MASK 0xff000000
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_B_SHIFT 0
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_G_SHIFT 8
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_R_SHIFT 16
|
|
Toshihiro Shimizu |
890ddd |
#define LPIXEL_M_SHIFT 24
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
!@ #
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*---------------------------------------------------------------------------*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
typedef enum {
|
|
Shinya Kitaoka |
120a6e |
PIX_NONE,
|
|
Shinya Kitaoka |
120a6e |
PIX_BW, /* 1 bit, B=0, W=1, first pixel in bit 7 */
|
|
Shinya Kitaoka |
120a6e |
PIX_WB, /* " , W=0, B=1, " */
|
|
Shinya Kitaoka |
120a6e |
PIX_GR8, /* grey tones, 8 bits */
|
|
Shinya Kitaoka |
120a6e |
PIX_CM8, /* color-mapped, 8 bits */
|
|
Shinya Kitaoka |
120a6e |
PIX_CM16, /* color-mapped, 16 bits */
|
|
Shinya Kitaoka |
120a6e |
PIX_RGB16, /* RGB 5+6+5 bits, red most significant */
|
|
Shinya Kitaoka |
120a6e |
PIX_XRGB1555, /* RGB 5+5+5 bits, 1 bit unused most significant(Apple format)
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
PIX_RGB, /* 1 byte per color channel, red first */
|
|
Shinya Kitaoka |
120a6e |
PIX_RGB_, /* LPIXEL, matte channel ignored, for display */
|
|
Shinya Kitaoka |
120a6e |
PIX_RGBM, /* LPIXEL, matte channel considered */
|
|
Shinya Kitaoka |
120a6e |
PIX_MBW16, /* 16 images of 1 bit per pixel, B=0, W=1 */
|
|
Shinya Kitaoka |
120a6e |
PIX_CM8S4, /* cmapped, 8 bits, standard SGI 16-color colormap */
|
|
Shinya Kitaoka |
120a6e |
PIX_CM8S8, /* cmapped, 8 bits, standard SGI 256-color colormap */
|
|
Shinya Kitaoka |
120a6e |
PIX_CM16S4, /* cmapped, 16 bits, standard SGI 16-color colormap */
|
|
Shinya Kitaoka |
120a6e |
PIX_CM16S8, /* cmapped, 16 bits, standard SGI 256-color colormap */
|
|
Shinya Kitaoka |
120a6e |
PIX_CM16S12, /* cmapped, 16 bits, standard SGI+Toonz 4096-color colormap */
|
|
Shinya Kitaoka |
120a6e |
PIX_CM24, /* color-mapped, 8+8+8 bits (pen, col, tone) + 8 msb bits extra*/
|
|
Shinya Kitaoka |
120a6e |
PIX_HOW_MANY
|
|
Toshihiro Shimizu |
890ddd |
} PIX_TYPE;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*---------------------------------------------------------------------------*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/* conversion macros
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#define BYTE_FROM_USHORT_MAGICFAC (256U * 255U + 1U)
|
|
Toshihiro Shimizu |
890ddd |
#define PIX_USHORT_FROM_BYTE(X) ((X) | ((X) << 8))
|
|
Shinya Kitaoka |
120a6e |
#define PIX_BYTE_FROM_USHORT(X) \
|
|
Shinya Kitaoka |
120a6e |
((((X)*BYTE_FROM_USHORT_MAGICFAC) + (1 << 23)) >> 24)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#define PIX_DITHER_BYTE_FROM_USHORT(X, R) \
|
|
Shinya Kitaoka |
120a6e |
(((((X)*BYTE_FROM_USHORT_MAGICFAC) - \
|
|
Shinya Kitaoka |
120a6e |
(((X)*BYTE_FROM_USHORT_MAGICFAC) >> 24)) + \
|
|
Shinya Kitaoka |
120a6e |
(R)) >> \
|
|
Shinya Kitaoka |
120a6e |
24)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*---------------------------------------------------------------------------*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#define PIX_RGB16_FROM_BYTES(R, G, B) \
|
|
Shinya Kitaoka |
120a6e |
(((R) << 8) & 0xf800 | ((G) << 3) & 0x7e0 | ((B) >> 3))
|
|
Toshihiro Shimizu |
890ddd |
#define PIX_RGB16_FROM_RGBX(L) (PIX_RGB16_FROM_BYTES((L).r, (L).g, (L).b))
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#define PIX_R_BYTE_FROM_RGB16(X) ((((X)&0xf800) >> 8) | (((X)&0xf800) >> 13))
|
|
Toshihiro Shimizu |
890ddd |
#define PIX_G_BYTE_FROM_RGB16(X) ((((X)&0x07e0) >> 3) | (((X)&0x07e0) >> 9))
|
|
Toshihiro Shimizu |
890ddd |
#define PIX_B_BYTE_FROM_RGB16(X) ((((X)&0x001f) << 3) | (((X)&0x001f) >> 2))
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#define PIX_FAST_R_BYTE_FROM_RGB16(X) (((X)&0xf800) >> 8)
|
|
Toshihiro Shimizu |
890ddd |
#define PIX_FAST_G_BYTE_FROM_RGB16(X) (((X)&0x07e0) >> 3)
|
|
Toshihiro Shimizu |
890ddd |
#define PIX_FAST_B_BYTE_FROM_RGB16(X) (((X)&0x001f) << 3)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#define PIX_RGB16_TO_RGB_(X, L) \
|
|
Shinya Kitaoka |
120a6e |
{ \
|
|
Shinya Kitaoka |
120a6e |
(L).r = PIX_R_BYTE_FROM_RGB16(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).g = PIX_G_BYTE_FROM_RGB16(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).b = PIX_B_BYTE_FROM_RGB16(X); \
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
#define PIX_RGB16_TO_RGBM(X, L) \
|
|
Shinya Kitaoka |
120a6e |
{ \
|
|
Shinya Kitaoka |
120a6e |
(L).r = PIX_R_BYTE_FROM_RGB16(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).g = PIX_G_BYTE_FROM_RGB16(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).b = PIX_B_BYTE_FROM_RGB16(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).m = 0xff; \
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
#define PIX_FAST_RGB16_TO_RGB_(X, L) \
|
|
Shinya Kitaoka |
120a6e |
{ \
|
|
Shinya Kitaoka |
120a6e |
(L).r = PIX_FAST_R_BYTE_FROM_RGB16(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).g = PIX_FAST_G_BYTE_FROM_RGB16(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).b = PIX_FAST_B_BYTE_FROM_RGB16(X); \
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
#define PIX_FAST_RGB16_TO_RGBM(X, L) \
|
|
Shinya Kitaoka |
120a6e |
{ \
|
|
Shinya Kitaoka |
120a6e |
(L).r = PIX_FAST_R_BYTE_FROM_RGB16(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).g = PIX_FAST_G_BYTE_FROM_RGB16(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).b = PIX_FAST_B_BYTE_FROM_RGB16(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).m = 0xff; \
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*---------------------------------------------------------------------------*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#define PIX_XRGB1555_FROM_BYTES(R, G, B) \
|
|
Shinya Kitaoka |
120a6e |
(((R) << 7) & 0x7c00 | ((G) << 2) & 0x3e0 | ((B) >> 3))
|
|
Toshihiro Shimizu |
890ddd |
#define PIX_XRGB1555_FROM_RGBX(L) (PIX_XRGB1555_FROM_BYTES((L).r, (L).g, (L).b))
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#define PIX_R_BYTE_FROM_XRGB1555(X) ((((X)&0x7c00) >> 7) | (((X)&0x7c00) >> 12))
|
|
Toshihiro Shimizu |
890ddd |
#define PIX_G_BYTE_FROM_XRGB1555(X) ((((X)&0x03e0) >> 2) | (((X)&0x03e0) >> 7))
|
|
Toshihiro Shimizu |
890ddd |
#define PIX_B_BYTE_FROM_XRGB1555(X) ((((X)&0x001f) << 3) | (((X)&0x001f) >> 2))
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#define PIX_FAST_R_BYTE_FROM_XRGB1555(X) (((X)&0x7c00) >> 7)
|
|
Toshihiro Shimizu |
890ddd |
#define PIX_FAST_G_BYTE_FROM_XRGB1555(X) (((X)&0x03e0) >> 2)
|
|
Toshihiro Shimizu |
890ddd |
#define PIX_FAST_B_BYTE_FROM_XRGB1555(X) (((X)&0x001f) << 3)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#define PIX_XRGB1555_TO_RGB_(X, L) \
|
|
Shinya Kitaoka |
120a6e |
{ \
|
|
Shinya Kitaoka |
120a6e |
(L).r = PIX_R_BYTE_FROM_XRGB1555(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).g = PIX_G_BYTE_FROM_XRGB1555(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).b = PIX_B_BYTE_FROM_XRGB1555(X); \
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
#define PIX_XRGB1555_TO_RGBM(X, L) \
|
|
Shinya Kitaoka |
120a6e |
{ \
|
|
Shinya Kitaoka |
120a6e |
(L).r = PIX_R_BYTE_FROM_XRGB1555(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).g = PIX_G_BYTE_FROM_XRGB1555(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).b = PIX_B_BYTE_FROM_XRGB1555(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).m = 0xff; \
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
#define PIX_FAST_XRGB1555_TO_RGB_(X, L) \
|
|
Shinya Kitaoka |
120a6e |
{ \
|
|
Shinya Kitaoka |
120a6e |
(L).r = PIX_FAST_R_BYTE_FROM_XRGB1555(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).g = PIX_FAST_G_BYTE_FROM_XRGB1555(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).b = PIX_FAST_B_BYTE_FROM_XRGB1555(X); \
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
#define PIX_FAST_XRGB1555_TO_RGBM(X, L) \
|
|
Shinya Kitaoka |
120a6e |
{ \
|
|
Shinya Kitaoka |
120a6e |
(L).r = PIX_FAST_R_BYTE_FROM_XRGB1555(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).g = PIX_FAST_G_BYTE_FROM_XRGB1555(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).b = PIX_FAST_B_BYTE_FROM_XRGB1555(X); \
|
|
Shinya Kitaoka |
120a6e |
(L).m = 0xff; \
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*---------------------------------------------------------------------------*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#define PIX_RGBM_TO_RGBM64(X, L) \
|
|
Shinya Kitaoka |
120a6e |
{ \
|
|
Shinya Kitaoka |
120a6e |
(L).r = PIX_USHORT_FROM_BYTE((X).r); \
|
|
Shinya Kitaoka |
120a6e |
(L).g = PIX_USHORT_FROM_BYTE((X).g); \
|
|
Shinya Kitaoka |
120a6e |
(L).b = PIX_USHORT_FROM_BYTE((X).b); \
|
|
Shinya Kitaoka |
120a6e |
(L).m = PIX_USHORT_FROM_BYTE((X).m); \
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
#define PIX_RGBM64_TO_RGBM(X, L) \
|
|
Shinya Kitaoka |
120a6e |
{ \
|
|
Shinya Kitaoka |
120a6e |
(L).r = PIX_BYTE_FROM_USHORT((X).r); \
|
|
Shinya Kitaoka |
120a6e |
(L).g = PIX_BYTE_FROM_USHORT((X).g); \
|
|
Shinya Kitaoka |
120a6e |
(L).b = PIX_BYTE_FROM_USHORT((X).b); \
|
|
Shinya Kitaoka |
120a6e |
(L).m = PIX_BYTE_FROM_USHORT((X).m); \
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/***************** WARNING !!!! *******
|
|
Toshihiro Shimizu |
890ddd |
This conversion uses random generated numbers;
|
|
Shinya Kitaoka |
120a6e |
Before you use it for the first time, execute
|
|
Toshihiro Shimizu |
890ddd |
the macro PIX_INIT_DITHER_RGBM64_TO_RGBM
|
|
Toshihiro Shimizu |
890ddd |
*****************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#define PIX_INIT_DITHER_RGBM64_TO_RGBM tnz_random_seed(180461);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#define PIX_DITHER_RGBM64_TO_RGBM(X, L) \
|
|
Shinya Kitaoka |
120a6e |
{ \
|
|
Shinya Kitaoka |
120a6e |
UINT random_round; \
|
|
Shinya Kitaoka |
120a6e |
random_round = tnz_random_uint() & ((1U << 24) - 1); \
|
|
Shinya Kitaoka |
120a6e |
\
|
|
Shinya Kitaoka |
120a6e |
(L).r = PIX_DITHER_BYTE_FROM_USHORT((X).r, random_round); \
|
|
Shinya Kitaoka |
120a6e |
(L).g = PIX_DITHER_BYTE_FROM_USHORT((X).g, random_round); \
|
|
Shinya Kitaoka |
120a6e |
(L).b = PIX_DITHER_BYTE_FROM_USHORT((X).b, random_round); \
|
|
Shinya Kitaoka |
120a6e |
(L).m = PIX_DITHER_BYTE_FROM_USHORT((X).m, random_round); \
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/***************************************/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#define PIX_RGB_TO_GREY(X) \
|
|
Shinya Kitaoka |
120a6e |
(((UINT)((X).r) * 19594 + (UINT)((X).g) * 38472 + (UINT)((X).b) * 7470 + \
|
|
Shinya Kitaoka |
120a6e |
(UINT)(1 << 15)) >> \
|
|
Shinya Kitaoka |
120a6e |
16)
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
#define PIX_CM32_MAP_TO_RGBM(PIX, MAP, RES) \
|
|
Shinya Kitaoka |
120a6e |
{ \
|
|
Shinya Kitaoka |
120a6e |
TUINT32 pix = (PIX); \
|
|
Shinya Kitaoka |
120a6e |
int t = pix & 0xff; \
|
|
Shinya Kitaoka |
120a6e |
if (t == 255) { \
|
|
Shinya Kitaoka |
120a6e |
int p = (pix >> 8) & 0xfff; \
|
|
Shinya Kitaoka |
120a6e |
(RES) = (MAP)[p]; \
|
|
Shinya Kitaoka |
120a6e |
} else if (t == 0) { \
|
|
Shinya Kitaoka |
120a6e |
int i = (pix >> 20) & 0xfff; \
|
|
Shinya Kitaoka |
120a6e |
(RES) = (MAP)[i]; \
|
|
Shinya Kitaoka |
120a6e |
} else { \
|
|
Shinya Kitaoka |
120a6e |
LPIXEL ink = (MAP)[(pix >> 20) & 0xfff]; \
|
|
Shinya Kitaoka |
120a6e |
LPIXEL paint = (MAP)[(pix >> 8) & 0xfff]; \
|
|
Shinya Kitaoka |
120a6e |
(RES).r = (int)(((255 - t) * ink.r + t * paint.r) / 255); \
|
|
Shinya Kitaoka |
120a6e |
(RES).g = (int)(((255 - t) * ink.g + t * paint.g) / 255); \
|
|
Shinya Kitaoka |
120a6e |
(RES).b = (int)(((255 - t) * ink.b + t * paint.b) / 255); \
|
|
Shinya Kitaoka |
120a6e |
(RES).m = (int)(((255 - t) * ink.m + t * paint.m) / 255); \
|
|
Shinya Kitaoka |
120a6e |
} \
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*---------------------------------------------------------------------------*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|