/*******************************************/
/*                                         */
/* colors.h                                */
/*                                         */
/* scol colors primitives                  */
/*                                         */
/* Loïc Berthelot, CryoNetworks, june 2002 */
/* update to zooengine, mars 2003          */
/*                                         */
/*******************************************/


/*
extern "C" {
#include "x/scolplugin.h"
}
#include "colors.h"
#include "macros.h"
*/







//
// separate RGB
//
void _COLOR_I_TO_BGR (int color, unsigned char *b, unsigned char *g, unsigned char *r)
{
	*b = (color>>16) &0xFF;
	*g = (color>>8) &0xFF;
	*r = color & 0xFF;
}


//
// separate RGB
//
void _COLOR_I15_TO_BGR (int color, unsigned char *b, unsigned char *g, unsigned char *r)
{
	*b = (color>>7) &0xF8;
	*g = (color>>2) &0xF8;
	*r = (color<<3) &0xF8;
}


//
// separate RGB
//
void _COLOR_I15_TO_RGB_BGR (int color, unsigned char *b, unsigned char *g, unsigned char *r)
{
	*r = (color>>7) &0xF8;
	*g = (color>>2) &0xF8;
	*b = (color<<3) &0xF8;
}

//
// assemble RGB
//
int _COLOR_BGR_TO_I (unsigned char b, unsigned char g, unsigned char r) 
{
	return ( ((b <<16) & 0xFF0000)  |  ((g <<8) & 0xFF00)  |  (r & 0xFF) );
}



int _COLOR_BGR_TO_I15 (unsigned char b, unsigned char g, unsigned char r)
{
	return ( ((b <<7) &0x7C00)  |  ((g <<2) &0x03E0)  |  (r>>3 &0x1F) );
}




//
// 16, 24 bits conversions
//
int _COLOR_CONVERT_16_24 (int value) { return ( ((value<<9) &0xF80000) | ((value<<6) &0xF800) | ((value<<3) &0xF8) );}

int _COLOR_CONVERT_24_16 (int value) { return ( ((value>>9) &0x7C00) | ((value>>6) &0x03E0) | ((value>>3) &0x1F) );}

int _COLOR_CONVERT_RGB_BGR_16 (int value) { return ( ((value>>10) &0x1F) | (value &0x03E0) | ((value<<10) &0x7C00) );}

int _COLOR_CONVERT_RGB_BGR_24 (int value) { return ( ((value>>16) &0xFF) | (value &0xFF00) | ((value<<16) &0xFF0000) );}

int _COLOR_CONVERT_RGB24_BGR16 (int value) { return ( ((value>>19) &0x1F) | ((value>>6) &0x03E0) | ((value <<7) &0x7C00) ); } 

int _COLOR_CONVERT_RGB16_BGR24 (int value) { return ( ((value>>7) &0xF8) | ((value<<6) &0xF800) | ((value<<19) &0xF80000) );}
