COLOR.H
资源名称:tc3d.zip [点击查看]
上传用户:abcdshs
上传日期:2007-01-07
资源大小:1858k
文件大小:1k
源码类别:
游戏
开发平台:
Visual C++
- // (C) Copyright 1996 by Anthony J. Carin. All Rights Reserved.
- #ifndef COLOR_H
- #define COLOR_H
- #include <windef.h>
- typedef unsigned int uint;
- typedef unsigned short ushort;
- typedef unsigned long ulong;
- typedef unsigned char uchar;
- class tccolor
- {
- public:
- tccolor() { val = 0; }
- tccolor(COLORREF c) { val = c; }
- tccolor(tccolor &c) { val = c.val; }
- operator COLORREF() { return val; }
- void operator =(COLORREF c) { val = c; }
- float rvalue() { return (float) GetRValue(val)/255.0f; }
- float gvalue() { return (float) GetGValue(val)/255.0f; }
- float bvalue() { return (float) GetBValue(val)/255.0f; }
- friend COLORREF operator +(tccolor& c, uchar v);
- friend COLORREF operator -(tccolor& c, uchar v);
- private:
- COLORREF val;
- };
- inline COLORREF operator +(tccolor& c, uchar v)
- {
- return RGB((((GetRValue(c.val)+v))<256) ? ((GetRValue(c.val))+v):255,
- (((GetGValue(c.val)+v))<256) ? ((GetGValue(c.val))+v):255,
- (((GetBValue(c.val)+v))<256) ? ((GetBValue(c.val))+v):255);
- }
- inline COLORREF operator -(tccolor& c, uchar v)
- {
- return RGB((((GetRValue(c.val)-v))>=0) ? ((GetRValue(c.val))-v):0,
- (((GetGValue(c.val)-v))>=0) ? ((GetGValue(c.val))-v):0,
- (((GetBValue(c.val)-v))>=0) ? ((GetBValue(c.val))-v):0);
- }
- #endif