remake show the bild

the GUI can show a bild with the colormap
This commit is contained in:
chenhuan 2019-10-28 22:14:42 +01:00
parent 76cc27841e
commit e6259c46e1
2 changed files with 34 additions and 17 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

View File

@ -1,19 +1,19 @@
#pragma comment(lib, "fltk.lib")
#pragma comment(lib, "wsock32.lib")
#pragma comment(lib, "comctl32.lib")
#pragma comment(linker, "/NODEFAULTLIB:LIBCMTD.lib")
#include <iostream> #include <iostream>
#include <Fl/Fl.H> #include <Fl/Fl.H>
#include <FL/Fl_Box.H> #include <FL/Fl_Box.H>
#include <FL/Fl_Window.H> #include <FL/Fl_Window.H>
#include <FL/Fl_PNG_Image.H> #include <FL/fl_draw.H>
#define window_size 400
#define window_height 600
#define window_width 800
/*****************************************************************************/ /*****************************************************************************/
/* This class provides a view to copy the offscreen surface to */ /* This class provides a view to copy the offscreen surface to */
int color_map[window_width][window_height];
class My_Window : public Fl_Window{ class My_Window : public Fl_Window{
int x,y,button; int x,y,button;
int handle(int e) int handle(int e)
@ -28,25 +28,42 @@ class My_Window : public Fl_Window{
return 1; return 1;
case FL_KEYBOARD: case FL_KEYBOARD:
button = Fl::event_button(); button = Fl::event_button();
std::cout<<"Keyboard:"<< button <<std::endl; std::cout<<"Keyboard:"<< (unsigned short)button <<std::endl;
return 1; return 1;
} }
} }
public: public:
My_Window(int x, int y, const char *l ) : Fl_Window(x,y,l){}; My_Window(int x, int y, const char *l ) : Fl_Window(x,y,l){};
}; };
class Pixel : public Fl_Widget {
Fl_Color color;
void draw(){
fl_draw_box(static_cast<Fl_Boxtype>(1), x(), y(), w(), h(), color);
}
public:
Pixel(int x,int y,int w,int h,int RGB) :
Fl_Widget(x,y,w,h,0) {
this->color = fl_rgb_color((uchar)((RGB&0xff000000)>>24),(uchar)((RGB&0xff0000)>>16),(uchar)((RGB&0xff00)>>8));
}
};
int main(int argc, char **argv) { int main(int argc, char **argv) {
for(int i=0;i<100;i++){
int x, y, button; for (int j = 0; j < 100 ; j++) {
My_Window* window = new My_Window(window_size, window_size, "example"); color_map[i][j]=0xff000000;
Fl_Box* box = new Fl_Box(10,10,380,380); }
}
My_Window* window = new My_Window(window_width, window_height, "example");
window->begin(); window->begin();
Fl_PNG_Image* background = new Fl_PNG_Image("../image/background.png"); for(int i=0;i<100;i++){
std::cout<<background->Fl_Image::fail()<<std::endl; for (int j = 0; j < 100 ; j++) {
box->image(background); new Pixel(i,j,1,1,color_map[i][j]);
box->redraw(); }
}
window->end(); window->end();
window->show(argc,argv); window->show(argc,argv);
return Fl::run(); return Fl::run();