//c++ -g -I../guicast test4.C ../guicast/x86_64/libguicast.a \ // -DHAVE_GL -DHAVE_XFT -I/usr/include/freetype2 -lGL -lX11 -lXext \ // -lXinerama -lXv -lpng -lfontconfig -lfreetype -lXft -pthread #include #include #include #include #include #include #include #include "bcwindowbase.h" #include "bcwindow.h" #include "bcsignals.h" #include "bccolors.h" #include "fonts.h" #include "thread.h" #include "vframe.h" class TestWindowGUI : public BC_Window { public: TestWindowGUI(int x, int y, int w, int h); ~TestWindowGUI(); }; class TestWindow : public Thread { TestWindowGUI *gui; public: TestWindow(int x, int y, int w, int h) : Thread(1,0,0) { gui = new TestWindowGUI(x,y,w,h); start(); } void draw(VFrame *vframe) { gui->draw_vframe(vframe, 0,0,gui->get_w(),gui->get_h(), 0,0,vframe->get_w(),vframe->get_h(), 0); gui->flash(); } void show_text(int tx, int ty, const char *fmt, ...); void close_window() { gui->close(0); } ~TestWindow() { delete gui; } void run() { gui->run_window(); } }; TestWindowGUI:: TestWindowGUI(int x, int y, int w, int h) : BC_Window("test", x,y, w,h, 100,100) { set_bg_color(BLACK); clear_box(0,0,get_w(),get_h()); flash(); set_font(MEDIUMFONT); } TestWindowGUI:: ~TestWindowGUI() { } void TestWindow::show_text(int tx, int ty, const char *fmt, ...) { char text[1024]; va_list ap; va_start(ap, fmt); vsprintf(text, fmt, ap); va_end(ap); gui->set_color(0xc080f0); gui->draw_text(tx,ty, text); gui->flash(); } const char *cmdl[] = { "transparency", "compressed", "rgb8", "rgb565", "bgr565", "bgr888", "bgr8888", "yuv420p", "yuv422p", "rgb888", "rgba8888", "rgb161616", "rgba16161616", "yuv888", "yuva8888", "yuv161616", "yuva16161616", "yuv411p", "uvy422", "yuv422", "argb8888", "abgr8888", "a8", "a16", "yuv101010", "vyu888", "uyva8888", "yuv444p", "yuv410p", "rgb_float", "rgba_float", "a_float", "rgb_floatp", "rgba_floatp", "yuv420pi", "ayuv16161616", "grey8", "grey16", "gbrp", }; void write_pgm(uint8_t *tp, int w, int h, const char *fmt, ...) { va_list ap; va_start(ap, fmt); char fn[256]; vsnprintf(fn, sizeof(fn), fmt, ap); va_end(ap); FILE *fp = !strcmp(fn,"-") ? stdout : fopen(fn,"w"); if( fp ) { fprintf(fp,"P5\n%d %d\n255\n",w,h); fwrite(tp,w,h,fp); fclose(fp); } } void write_ppm(uint8_t *tp, int w, int h, const char *fmt, ...) { va_list ap; va_start(ap, fmt); char fn[256]; vsnprintf(fn, sizeof(fn), fmt, ap); va_end(ap); FILE *fp = !strcmp(fn,"-") ? stdout : fopen(fn,"w"); if( fp ) { fprintf(fp,"P6\n%d %d\n255\n",w,h); fwrite(tp,3*w,h,fp); if( fp != stdout ) fclose(fp); } } int64_t tm = 0, tn = 0; static int diff_vframe(VFrame &afrm, VFrame &bfrm) { int n = 0, m = 0; int w = afrm.get_w(), h = afrm.get_h(); uint8_t **arows = afrm.get_rows(); uint8_t **brows = bfrm.get_rows(); for( int y=0; y