MGCL V10  V10
MGCL V10
 全て クラス 名前空間 関数 変数 型定義 列挙型 列挙値 フレンド グループ ページ
Pixel.h
1 /********************************************************************/
2 /* Copyright (c) 2015 DG Technologies Inc. and Yuzi Mizuno */
3 /* All rights reserved. */
4 /********************************************************************/
5 #ifndef _MGPixel_HH_
6 #define _MGPixel_HH_
7 
8 #include "mg/MGCL.h"
9 
14 
18 class MG_DLL_DECLR MGPixel{
19 
20 public:
21 
22 MGPixel(unsigned data=0){m_pixel.uint=data;};
23 
25 MGPixel(const MGColor& color);
26 
27 unsigned char getRed()const{return m_pixel.uchar[0];};
28 unsigned char getGreen()const{return m_pixel.uchar[1];};
29 unsigned char getBlue()const{return m_pixel.uchar[2];};
30 unsigned char getAlpha()const{return m_pixel.uchar[3];};
31 
32 unsigned int getPixel()const{return m_pixel.uint;};
33 const unsigned char* getPixelAsChar()const{return m_pixel.uchar;};
34 
35 void setRed(unsigned char R){m_pixel.uchar[0]=R;};
36 void setGreen(unsigned char G){m_pixel.uchar[1]=G;};
37 void setBlue(unsigned char B){m_pixel.uchar[2]=B;};
38 void setAlpha(unsigned char A){m_pixel.uchar[3]=A;};
39 
41 void setRGB(const MGPixel& pixel2);
42 
43 void setPixel(unsigned int pixel){m_pixel.uint=pixel;};
44 
45 unsigned char& operator[](unsigned i){return m_pixel.uchar[i];};
46 const unsigned char& operator[](unsigned i)const{return m_pixel.uchar[i];};
47 MGPixel& operator&=(unsigned int data){m_pixel.uint &=data;return *this;};
48 MGPixel& operator|=(unsigned int data){m_pixel.uint |=data;return *this;};
49 
51 bool isNull()const{return m_pixel.uint==0;};
52 
53 private:
54 
59 union pixelData{
60  unsigned int uint;
61  unsigned char uchar[4];//[0-2]=(R,G,B), [3]=A.
62 };
63 
64 pixelData m_pixel;//One pixel data.
65 
66 };
67  // end of DisplayHandling group
69 #endif
void setRed(unsigned char R)
Definition: Pixel.h:35
const unsigned char * getPixelAsChar() const
Definition: Pixel.h:33
void setBlue(unsigned char B)
Definition: Pixel.h:37
unsigned char getAlpha() const
Definition: Pixel.h:30
unsigned int getPixel() const
Definition: Pixel.h:32
MGPixel(unsigned data=0)
Definition: Pixel.h:22
unsigned char & operator[](unsigned i)
Definition: Pixel.h:45
MGColor defines the OpenGL color (R,G,B,A).
Definition: Color.h:26
unsigned char getGreen() const
Definition: Pixel.h:28
const unsigned char & operator[](unsigned i) const
Definition: Pixel.h:46
void setPixel(unsigned int pixel)
Definition: Pixel.h:43
MGPixel & operator|=(unsigned int data)
Definition: Pixel.h:48
void setGreen(unsigned char G)
Definition: Pixel.h:36
bool isNull() const
Test if this pixel is null pixel(that is, RGBA=(0,0,0,0)).
Definition: Pixel.h:51
unsigned char getRed() const
Definition: Pixel.h:27
unsigned char getBlue() const
Definition: Pixel.h:29
void setAlpha(unsigned char A)
Definition: Pixel.h:38
MGPixel & operator&=(unsigned int data)
Definition: Pixel.h:47
Define MGPixel Class of (R,G,B,A) pixel data.
Definition: Pixel.h:18