home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
utilities
/
utilss
/
sprtools
/
h
/
colours
< prev
next >
Wrap
Text File
|
1994-07-18
|
3KB
|
83 lines
/************************************************************************
* *
* colours.h *
* ========= *
* *
* RISCOS sprite style bitmap colour matching library *
* Uses spr_info generic bitmap interface from sprite.c library *
* *
* Version 1.10 (05-May-1994) *
* *
* (C) 1994 DEEJ Technology PLC *
* *
************************************************************************/
#ifndef __colours_h
#define __colours_h
#include "sprite.h"
/*************************** Machine configuration ***************************/
#ifdef RISCOS
#define REGISTER
#else
/* Sun & HP compilers */
#define REGISTER register
#define SQR_TABLE
#endif
#ifdef M68K
#define MULT
#endif
/*
#define CACHE_STAT
*/
/********************************* Constants *********************************/
/* COLOUR weights designed to give a 16 bit intensity */
#define RED_WEIGHT 19595 /* 0.299 */
#define GREEN_WEIGHT 38469 /* 0.587 */
#define BLUE_WEIGHT 7472 /* 0.114 */
#define GREY_WEIGHT 65536 /* 1.000 */
#define GREY_SHIFT 16
/* closest_rgb cache table size & hashing algorithm */
#define CACHE_SIZE (255*21+1)
#define HASH(r,g,b) (((r & 255)<<2) + ((g & 255)<<4) + (b & 255))
/*
#define CACHE_SIZE 4096
#define HASH(r,g,b) ((r & 0xC3) | ((g & 0xC3)<<2) | ((b & 0xC3)<<4))
#define CACHE_SIZE 4096
#define HASH(r,g,b) (((r & 0xF0)>>4) | (g & 0xF0) | ((b & 0xF0)<<4))
*/
/********************************** Macros **********************************/
/* RGB macros, for uint r,g,b - value must also be uint */
#define SPLIT_RGB(value) r = (value >> 8) & 0xFF; \
g = (value >> 16) & 0xFF; \
b = (value >> 24) & 0xFF;
#define JOIN_RGB(value) value = ((r<<8)+(g<<16)+(b<<24));
/* RGB range rounding for signed integer components */
#define RANGE_RGB(value) if(value<0) value=0; if(value>255) value=255
/* maximum positive integer difference */
#define MAX_DIFF 0x7FFFFFFF
/**************************** Function prototypes ****************************/
extern void closest_rgb_func(spr_info_str*);
extern pix_str *closest_rgb(spr_info_str*, pix_str*);
#endif