summaryrefslogtreecommitdiff
path: root/im/src/im_colorutil.cpp
blob: 9e96c6595bdc5366254b56b6376480ad13bf2342 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/** \file
 * \brief Color Utilities
 *
 * See Copyright Notice in im_lib.h
 * $Id: im_colorutil.cpp,v 1.1 2008/10/17 06:10:16 scuri Exp $
 */


#include <stdlib.h>
#include <memory.h>
#include <string.h>

#include "im.h"
#include "im_util.h"

long imColorEncode(unsigned char Red, unsigned char Green, unsigned char Blue)
{
	return (((long)Red) << 16) | (((long)Green) << 8) | ((long)Blue);
}

void imColorDecode(unsigned char* Red, unsigned char* Green, unsigned char* Blue, long Color)
{
	if (Red) *Red = (imbyte)(Color >> 16);
	if (Green) *Green = (imbyte)(Color >> 8);
	if (Blue) *Blue = (imbyte)Color;
}