📄 elrgb8.h
字号:
#ifndef ELRGB8_H
#define ELRGB8_H
#include "element.h"
class mgcRGB8 : public mgcElement
{
// object information
public:
mgcRGB8 () : mgcElement(type,&value)
{ value = 0; }
mgcRGB8 (const unsigned int& _value) : mgcElement(type,&value)
{ value = _value; }
mgcRGB8 (const mgcElement& element) : mgcElement(type,&value)
{ *this = element; }
static unsigned int Color (unsigned char r, unsigned char g, unsigned char b)
{
return (unsigned(b))|((unsigned(g))<<8)|((unsigned(r))<<16);
}
static unsigned char GetBlue (unsigned int color)
{
return (unsigned char)(color & 0x000000FF);
}
static unsigned char GetGreen (unsigned int color)
{
return (unsigned char)((color & 0x0000FF00) >> 8);
}
static unsigned char GetRed (unsigned int color)
{
return (unsigned char)((color & 0x00FF0000) >> 16);
}
operator unsigned int ()
{ return value; }
mgcRGB8& operator= (unsigned int _value)
{ value = _value; return *this; }
mgcRGB8& operator= (const mgcRGB8& derived)
{ value = derived.value; return *this; }
mgcRGB8& operator= (const mgcElement& element);
int operator== (const mgcRGB8& derived) const
{ return value == derived.value; }
int operator!= (const mgcRGB8& derived) const
{ return value != derived.value; }
friend istream& operator>> (istream& istr, mgcRGB8& derived)
{ return istr >> derived.value; }
friend ostream& operator<< (ostream& ostr, const mgcRGB8& derived)
{ return ostr << derived.value; }
private:
unsigned 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 int*)trg; }
static void Output (ostream& ostr, const void* src)
{ ostr << *(unsigned int*)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 mgcRGB8_key = mgcRGB8::Register();
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -