lib/FrameGraphics.hh
00001 // 繝輔Ξ繝シ繝�繝舌ャ繝輔ぃ繧ー繝ゥ繝輔ぅ繝�繧ッ繧ケ繧ッ繝ゥ繧ケ
00002 // 2011/02/07 Yuki YOKOKURA
00003 //
00004 // 逕サ髱「荳翫↓蝗ウ遲峨�ョ謠冗判繧定。後>縺セ縺吶�ゅ◆縺�縺暦シ�/dev/fb* 縺悟ソ�隕√��
00005 //
00006 // Copyright (C) 2011 Yuki YOKOKURA
00007 // This program is free software;
00008 // you can redistribute it and/or modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 3 of the License, or any later version.
00010 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
00011 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00012 // See the GNU General Public License for more details <http://www.gnu.org/licenses/>.
00013 // Besides, you can negotiate about other options of licenses instead of GPL.
00014 // If you would like to get other licenses, please contact us<yuki@katsura.sd.keio.ac.jp>.
00015 
00016 #ifndef FRAMEGRAPHICS
00017 #define FRAMEGRAPHICS
00018 
00019 #include <unistd.h>
00020 #include <stdio.h>
00021 #include <fcntl.h>
00022 #include <linux/fb.h>
00023 #include <linux/fs.h>
00024 #include <sys/mman.h>
00025 #include <sys/ioctl.h>
00026 #include <string.h>
00027 
00028 
00029 // 濶イ縺ョ螳夂セゥ (濶イ豺ア蠎ヲ16bit繝「繝シ繝臥畑)
00030 // 繝薙ャ繝医ヱ繧ソ繝シ繝ウ MSB RRRRRGGGGGGBBBBB LSB (襍、�シ壹ン繝�繝�15�ス�11 邱托シ壹ン繝�繝�10�ス�5 髱抵シ壹ン繝�繝�4�ス�0)
00031 // 螳溘�ッ襍、髱偵↓豈斐∋邱代�ョ蛻�隗」閭ス縺�1bit蛻�縺�縺大、壹>
00032 // 莉・荳九�ッ蝓コ譛ャ濶イ縺ョ螳夂セゥ  縺薙�ョ莉悶↓繧ょ享謇九↓螂ス縺阪↑濶イ繧剃ス懊l繧�
00033 #define FG_COLOR_RED            0xF800  // 襍、
00034 #define FG_COLOR_GREEN          0x07E0  // 邱�
00035 #define FG_COLOR_BLUE           0x001F  // 髱�
00036 #define FG_COLOR_CYAN           FG_COLOR_GREEN | FG_COLOR_BLUE  // 豌エ (繧キ繧「繝ウ)              // OR繧貞叙繧九→濶イ縺瑚カウ縺帙k繧茨ス�!
00037 #define FG_COLOR_MAGENTA        FG_COLOR_RED | FG_COLOR_BLUE    // 邏ォ (繝槭ぞ繝ウ繧ソ)
00038 #define FG_COLOR_YELLOW         FG_COLOR_RED | FG_COLOR_GREEN   // 鮟� (繧、繧ィ繝ュ繝シ)
00039 #define FG_COLOR_BLACK          0x0000  // 鮟�
00040 #define FG_COLOR_WHITE          0xFFFF  // 逋ス
00041 #define FG_COLOR_GRAY50         0x7BEF  // 轣ー 霈晏コヲ50�シ�
00042 #define FG_COLOR_GRAY25         0x39E7  // 轣ー 霈晏コヲ25�シ�
00043 
00044 class FrameGraphics {
00045         // 繝輔Ξ繝シ繝�繝舌ャ繝輔ぃ繧ッ繝ゥ繧ケ
00046         private:
00047                 FrameGraphics(const FrameGraphics&);                                    // 繧ウ繝斐�シ繧ウ繝ウ繧ケ繝医Λ繧ッ繧ソ菴ソ逕ィ遖∵ュ「
00048                 const FrameGraphics& operator=(const FrameGraphics&);   // 莉」蜈・貍皮ョ怜ュ蝉スソ逕ィ遖∵ュ「
00049                 int FBfd;               // 繝輔Ξ繝シ繝�繝舌ャ繝輔ぃ 繝輔ぃ繧、繝ォ繝�繧」繧ケ繧ッ繝ェ繝励ち
00050                 short *FBptr;   // 繝輔Ξ繝シ繝�繝舌ャ繝輔ぃ 繝昴う繝ウ繧ソ
00051                 struct fb_fix_screeninfo finfo; // 蝗コ螳壽ュ蝣ア讒矩��菴�
00052                 struct fb_var_screeninfo vinfo; // 蜿ッ螟画ュ蝣ア讒矩��菴�
00053                 int width;              // [px]         讓ェ蟷�
00054                 int height;             // [px]         鬮倥&
00055                 int depth;              // [bits]       濶イ豺ア蠎ヲ
00056                 int size;               // [bytes]      逕サ髱「縺ョ螟ァ縺阪&
00057                 int length;             //                      繝輔Ξ繝シ繝�繝舌ャ繝輔ぃ繝昴う繝ウ繧ソ縺ョ髟キ縺�
00058         
00059         public:
00060                 FrameGraphics(const char* device);                                                      // 繧ウ繝ウ繧ケ繝医Λ繧ッ繧ソ 繝輔Ξ繝シ繝�繝舌ャ繝輔ぃ蛻晄悄蛹�
00061                 ~FrameGraphics(void);                                                                           // 繝�繧ケ繝医Λ繧ッ繧ソ   繝輔Ξ繝シ繝�繝舌ャ繝輔ぃ髢区叛
00062                 void ShowParam(void);                                                                           // 逕サ髱「諠�蝣ア縺ョ陦ィ遉コ
00063                 void DrawPoint(int x, int y, short color);                                      // 轤ケ縺ョ謠冗判
00064                 void DrawLine(int x1, int y1, int x2, int y2, short color);     // 逶エ邱壹�ョ謠冗判
00065                 void DrawRect(int x, int y, int w, int h, short color);         // 髟キ譁ケ蠖「縺ョ謠冗判(濶イ縺ッ蝪励i縺ェ縺�)
00066                 void DrawRectFill(int x, int y, int w, int h, short color);     // 髟キ譁ケ蠖「縺ョ謠冗判(濶イ繧貞。励k)
00067                 void ClearScreen(void);                                                                         // 逕サ髱「縺ョ豸亥悉
00068                 void ClearRect(int x, int y, int w, int h);                                     // 髟キ譁ケ蠖「縺ョ遽�蝗イ蜀�繧呈カ亥悉
00069                 int GetWidth(void);                                                                                     // 逕サ髱「縺ョ蟷�縺ョ蜿門セ�
00070                 int GetHeight(void);                                                                            // 逕サ髱「縺ョ鬮倥&縺ョ蜿門セ�
00071         
00072 
00073 };
00074 
00075 #endif
00076 
 All Classes Files