📄 elrgb5.h
字号:
#ifndef ELRGB5_H
#define ELRGB5_H
#include "element.h"
class mgcRGB5 : public mgcElement
{
// object information
public:
mgcRGB5 () : mgcElement(type,&value)
{ value = 0; }
mgcRGB5 (const unsigned short& _value) : mgcElement(type,&value)
{ value = _value; }
mgcRGB5 (const mgcElement& element) : mgcElement(type,&value)
{ *this = element; }
static unsigned short Color (unsigned char r, unsigned char g, unsigned char b)
{
return ( unsigned(b) >> 3 )
| ((unsigned(g) >> 3 ) << 5 )
| ((unsigned(r) >> 3 ) << 10 );
}
static unsigned char GetBlue (unsigned short color)
{
return (unsigned char)(color & 0x001F);
}
static unsigned char GetGreen (unsigned short color)
{
return (unsigned char)((color & 0x03E0) >> 5);
}
static unsigned char GetRed (unsigned short color)
{
return (unsigned char)((color & 0x7C00) >> 10);
}
operator unsigned short ()
{ return value; }
mgcRGB5& operator= (unsigned short _value)
{ value = _value; return *this; }
mgcRGB5& operator= (const mgcRGB5& derived)
{ value = derived.value; return *this; }
mgcRGB5& operator= (const mgcElement& element);
int operator== (const mgcRGB5& derived) const
{ return value == derived.value; }
int operator!= (const mgcRGB5& derived) const
{ return value != derived.value; }
friend istream& operator>> (istream& istr, mgcRGB5& derived)
{ return istr >> derived.value; }
friend ostream& operator<< (ostream& ostr, const mgcRGB5& derived)
{ return ostr << derived.value; }
private:
int value;
// class information
public:
static const int type;
static const char* description;
static const int size;
static int Register ();
static void ToUshort (int quantity, void* src, void* trg);
static void ToUint (int quantity, void* src, void* trg);
static void ToUlong (int quantity, void* src, void* trg);
static void Input (istream& istr, void* trg)
{ istr >> *(unsigned short*)trg; }
static void Output (ostream& ostr, const void* src)
{ ostr << *(unsigned short*)src; }
// error handling
public:
static int verbose;
static unsigned error;
static void Report (ostream& ostr);
private:
static const unsigned registration_failed;
static const char* message[1];
static int Number (unsigned single_error);
static void Report (unsigned single_error);
};
static int mgcRGB5_key = mgcRGB5::Register();
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -