static htsmsg_t * hts_settings_load_one(const char *filename) { ssize_t n; char *mem; fb_file *fp; htsmsg_t *r = NULL; /* Open */ if (!(fp = fb_open(filename, 1, 0))) return NULL; /* Load data */ mem = malloc(fb_size(fp)+1); n = fb_read(fp, mem, fb_size(fp)); if (n >= 0) mem[n] = 0; /* Decode */ if(n == fb_size(fp)) r = htsmsg_json_deserialize(mem); /* Close */ fb_close(fp); free(mem); return r; }
int main(int argc, const char *argv[]) { int ret; char ch; srand(time(NULL)); ret = fb_open(); key_init(); draw_back(); draw_grid(); signal(SIGALRM, sig_handler); alarm(1); while (1) { ch = getchar(); switch (ch) { case 'a': if(canleft(pos_x, pos_y, cur_type, arr)) { draw_type(pos_x, pos_y, cur_type, BACK); pos_x--; } break; case 'd': if(canright(pos_x, pos_y, cur_type, arr)) { draw_type(pos_x, pos_y, cur_type, BACK); pos_x++; } break; case 's': if(candown(pos_x, pos_y, cur_type, arr)) { draw_type(pos_x, pos_y, cur_type, BACK); pos_y++; } break; case 'w': if(canchange(pos_x,pos_y,cur_type,arr)) { draw_type(pos_x, pos_y, cur_type, BACK); type_chg(&cur_type); } break; default : break; } draw_type(pos_x, pos_y, cur_type, COLOR); draw_grid(); if(!candown(pos_x, pos_y, cur_type, arr)) { draw_flag(pos_x, pos_y, cur_type, arr); if(gameover(arr)) { exit(0); } deleteone(arr); pos_x = XNUM/2; pos_y = 0; cur_type = rand()%14; } } fb_close(); return 0; }
int main(int argc, char **argv) { struct vfont *vfp; bu_setprogname(argv[0]); if (!get_args(argc, argv)) { fputs(usage, stderr); bu_exit(1, NULL); } if ((fbp = fb_open(framebuffer, scr_width, scr_height)) == NULL) { fprintf(stderr, "fblabel: Unable to open framebuffer %s\n", framebuffer); bu_exit(12, NULL); } if (clear) { fb_clear(fbp, PIXEL_NULL); } if ((vfp = vfont_get(font1)) == VFONT_NULL) { fprintf(stderr, "fblabel: Can't get font \"%s\"\n", font1 == NULL ? "(null)" : font1); bu_exit(1, NULL); } do_line(vfp, textstring); fb_close(fbp); vfont_free(vfp); return 0; }
// TODO: this could do with being more efficient int fb_stat ( const char *path, struct filebundle_stat *st ) { int ret = 1; fb_dir *dir; fb_file *fp; if (*path == '/') { struct stat _st; if (!lstat(path, &_st)) { st->type = FB_DIRECT; st->is_dir = S_ISDIR(_st.st_mode) ? 1 : 0; st->size = _st.st_size; ret = 0; } } else if ((dir = fb_opendir(path))) { st->type = dir->type; st->is_dir = 1; st->size = 0; ret = 0; fb_closedir(dir); } else if ((fp = fb_open(path, 0, 0))) { st->type = fp->type; st->is_dir = 0; st->size = fp->size; ret = 0; fb_close(fp); } return ret; }
int main() { FBDEV fbdev; memset(&fbdev,0,sizeof(FBDEV)); strcpy(fbdev.dev,"/dev/fb0"); if(0 == fb_open(&fbdev)){ printf("Open fail!!\n"); return -1; } //打印frame buffer 所占内存的开始地址 pmem_start(&fbdev); //打印FB_TYPE p_type(&fbdev); //打印可见清晰度 p_visible_res(&fbdev); //打印虚拟分辨率 p_virt_res(&fbdev); //打印虚拟到可见的偏移量 p_offset(&fbdev); //打印每个像素的位数 p_bpp(&fbdev); //打印R,G,B和透明度 p_rgbt(&fbdev); //打印在内存中的高度和宽度 p_hw(&fbdev); fb_close(&fbdev); return 0; }
int main(int argc, char **argv) { int c; FBIO *fbp; while ((c = bu_getopt(argc, argv, "F:h?")) != -1) { switch (c) { case 'F': framebuffer = bu_optarg; break; default: /* '?' */ (void)fputs(usage, stderr); return 1; } } if (argc > ++bu_optind) { fprintf(stderr, "fbfree: excess argument(s) ignored\n"); } if ((fbp = fb_open(framebuffer, 0, 0)) == FBIO_NULL) { fprintf(stderr, "fbfree: Can't open frame buffer\n"); return 1; } return fb_free(fbp); }
struct FB * fb_create(void) { memset(&g_fb, 0, sizeof(struct FB)); if (fb_open(&g_fb)) { return NULL; } return &g_fb; }
int main(int argc, char **argv) { register int i; struct timeval tv; if ( !get_args( argc, argv ) ) { (void)fputs(usage, stderr); bu_exit( 1, NULL ); } if ( fps > 0.0 ) { tv.tv_sec = (long) (1.0 / fps); tv.tv_usec = (long) (((1.0 / fps) - tv.tv_sec) * 1000000); } if ( (fbp = fb_open( NULL, size, size)) == FBIO_NULL ) { fprintf(stderr, "fbcmrot: fb_open failed\n"); return 1; } local_inp = &cm1; local_outp = &cm2; fb_rmap( fbp, local_inp ); while (1) { register int from; ColorMap *tp; /* Build color map for current value */ for ( i=0, from = increment; i < 256; i++, from++ ) { if ( from < 0 ) from += 256; else if ( from > 255 ) from -= 256; local_outp->cm_red[i] = local_inp->cm_red[from]; local_outp->cm_green[i] = local_inp->cm_green[from]; local_outp->cm_blue[i] = local_inp->cm_blue[from]; } fb_wmap( fbp, local_outp ); tp = local_outp; local_outp = local_inp; local_inp = tp; if ( fps > 0.0 ) { fd_set readfds; FD_ZERO(&readfds); FD_SET(fileno(stdin), &readfds); select(fileno(stdin)+1, &readfds, (fd_set *)0, (fd_set *)0, &tv); } if ( onestep ) break; } fb_close( fbp ); return 0; }
int load_565rle_image(char *fn) { struct FB fb; struct stat s; unsigned short *data, *bits, *ptr; unsigned count, max; int fd; if (vt_set_mode(1)) return -1; fd = open(fn, O_RDONLY); if (fd < 0) { ERROR("cannot open '%s'\n", fn); goto fail_restore_text; } if (fstat(fd, &s) < 0) { goto fail_close_file; } data = mmap(0, s.st_size, PROT_READ, MAP_SHARED, fd, 0); if (data == MAP_FAILED) goto fail_close_file; if (fb_open(&fb)) goto fail_unmap_data; max = fb_width(&fb) * fb_height(&fb); ptr = data; count = s.st_size; bits = fb.bits; while (count > 3) { unsigned n = ptr[0]; if (n > max) break; android_memset16(bits, ptr[1], n << 1); bits += n; max -= n; ptr += 2; count -= 4; } munmap(data, s.st_size); fb_update(&fb); fb_close(&fb); close(fd); unlink(fn); return 0; fail_unmap_data: munmap(data, s.st_size); fail_close_file: close(fd); fail_restore_text: vt_set_mode(0); return -1; }
int fb_create(void) { memset(&g_fb, 0, sizeof(struct FB)); if (fb_open(&g_fb)) { return -1; } return 0; }
/* * D O _ F B */ void do_fb(void) { FBIO *fbp; if ( (fbp = fb_open( framebuffer, 0, 0 )) == FBIO_NULL ) { bu_exit( 2, "Unable to open framebuffer\n" ); } if ( fb_wmap( fbp, &map ) < 0 ) fprintf( stderr, "fbgammamod: unable to write color map\n"); fb_close(fbp); }
int screen_init(void) { if (draw_init()) goto err1; if (fb_open(fb)) goto err2; return 0; err2: draw_uninit(); err1: return -1; }
int main() { DeviceFB *pDeviceFb = fb_open("/dev/fb0"); if (pDeviceFb) { printf("w:%d h:%d bpp:%d\n", pDeviceFb->vinfo.xres, pDeviceFb->vinfo.yres, pDeviceFb->vinfo.bits_per_pixel); fb_close(pDeviceFb); } return 0; }
int main(void) { int ret, c; ret = fb_open(); if (ret != 0) { fprintf(stderr, "fb_open() error.\n"); exit(1); } init_board(); fb_close(); return 0; }
int main(int argc, char **argv) { fb *fbp; FILE *fp; int fbsize = 512; int i; while (argc > 1) { if (BU_STR_EQUAL(argv[1], "-H")) { fbsize = 1024; } else if (argv[1][0] == '-') { if ( (!BU_STR_EQUAL(argv[1], "-?")) && (!BU_STR_EQUAL(argv[1], "-h")) ) fprintf(stderr, "fb-cmap: unknown flag %s\n", argv[1]); bu_exit(1, "%s", usage); } else break; /* must be a filename */ argc--; argv++; } if (argc > 1) { if ((fp = fopen(argv[1], "wb")) == NULL) { fprintf(stderr, "fb-cmap: can't open \"%s\"\n", argv[1]); bu_exit(2, "%s", usage); } } else { fp = stdout; if (isatty(fileno(fp))) fprintf(stderr, "%s Program continues running:\n", usage); } if ((fbp = fb_open(NULL, fbsize, fbsize)) == FB_NULL) bu_exit(2, "Unable to open framebuffer\n"); i = fb_rmap(fbp, &cm); fb_close(fbp); if (i < 0) { bu_exit(3, "fb-cmap: can't read colormap\n"); } for (i = 0; i <= 255; i++) { fprintf(fp, "%d\t%04x %04x %04x\n", i, cm.cm_red[i], cm.cm_green[i], cm.cm_blue[i]); } return 0; }
void fb_init(void) { Debug("fb_init()\n"); fb_open(); fb_get_var(); memcpy(&saved_var, &fb_var, sizeof(struct fb_var_screeninfo)); //saved_var = fb_var; if (fb_var.xoffset || fb_var.yoffset || fb_var.accel_flags) { fb_var.xoffset = 0; fb_var.yoffset = 0; fb_var.accel_flags = 0; fb_set_var(); } fb_get_fix(); var_fix_validate(); memcpy(&saved_fix, &fb_fix, sizeof(struct fb_var_screeninfo)); //saved_fix = fb_fix; switch (fb_fix.visual) { case FB_VISUAL_MONO01: case FB_VISUAL_MONO10: case FB_VISUAL_TRUECOLOR: /* no colormap */ break; case FB_VISUAL_PSEUDOCOLOR: case FB_VISUAL_STATIC_PSEUDOCOLOR: cmap_init(1<<fb_var.bits_per_pixel); break; case FB_VISUAL_DIRECTCOLOR: cmap_init(1<<(max(max(fb_var.red.length, fb_var.green.length), max(fb_var.blue.length, fb_var.transp.length)))); break; } if (fb_cmap.len) { fb_get_cmap(); saved_cmap = fb_cmap; ALLOC_AND_SAVE_COMPONENT(red); ALLOC_AND_SAVE_COMPONENT(green); ALLOC_AND_SAVE_COMPONENT(blue); if (fb_cmap.transp) ALLOC_AND_SAVE_COMPONENT(transp); } fb_map(); fb_save(); fb_clear(); }
int main(int argc, const char *argv[]) { system("clear"); int ret,ch; ret = fb_open(); //draw_element(100, 100, 0x75); //draw_element(150, 100, PINK); //exit(1); struct termios tc, old_tc; tcgetattr(0, &tc);//0是输入 tcgetattr(0, &old_tc);//用于下面恢复 tc.c_lflag &= (~ICANON);//启动食品模式 tc.c_lflag &= (~ECHO);//ECHO 使用回显 &~(ECHO) 取消回显 tcsetattr(0, TCSANOW, &tc);//TCSANOW 立刻生效 init(); init_current_block(); draw_picture(ROW_CANVAS, 0x1a, IS_DRAW); signal(SIGALRM, sig_handler); alarm(1); while (1) { ch = getchar(); if (ch == 'q') {//exit break; } if (ch =='w') { change(); } if (ch =='a') { left(); } if (ch =='s') { down(); } if (ch =='d') { right(); } } tcsetattr(0, TCSANOW, &old_tc); fb_close(); return 0; }
void fbdemo_init(struct fbdemos_scaffold **out) { struct fbdemos_scaffold *fbs = CALLOC_STRUCT(fbdemos_scaffold); int rv; if(getenv("ETNA_MSAA_SAMPLES")) fbdemos_msaa_samples = atoi(getenv("ETNA_MSAA_SAMPLES")); rv = viv_open(VIV_HW_3D, &fbs->conn); if(rv!=0) { fprintf(stderr, "Error opening device\n"); exit(1); } printf("Succesfully opened device\n"); rv = fb_open(fbs->conn, 0, &fbs->fb); if(rv!=0) { exit(1); } fbs->width = fbs->fb.fb_var.xres; fbs->height = fbs->fb.fb_var.yres; /* Create screen */ if((fbs->screen = etna_screen_create(fbs->conn)) == NULL) { printf("Unable to create screen context\n"); exit(1); } if((fbs->pipe = fbs->screen->context_create(fbs->screen, NULL)) == NULL) { printf("Unable to create etna context\n"); exit(1); } fbs->ctx = etna_pipe_context(fbs->pipe)->ctx; if(etna_bswap_create(fbs->ctx, &fbs->buffers, fbs->fb.num_buffers, (etna_set_buffer_cb_t)&fb_set_buffer, (etna_copy_buffer_cb_t)&etna_fb_copy_buffer, &fbs->fb) != ETNA_OK) { printf("Unable to create buffer swapper\n"); exit(1); } _fbs = fbs; *out = fbs; }
int fb_off_all() { int fp, i; for (i = 0; i < TOTAL_FB_NUM; i++) { fp = fb_open(i); if (fp < 0) return -1; if (ioctl(fp, FBIOBLANK, FB_BLANK_POWERDOWN) < 0) ALOGE("%s:: FBIOBLANK failed", __func__); fb_off(fp); fb_close(fp); } return 0; }
/* f b _ S e t u p ( ) */ int fb_Setup(char *file, int size) { if ( BU_STR_EQUAL( file, "/dev/remote" ) ) file = "/dev/debug"; prnt_Event( "Opening device..." ); if (((fbiop = fb_open(file[0] == '\0' ? NULL : file, size, size)) == FBIO_NULL) || (fb_ioinit( fbiop ) == -1) || (fb_wmap( fbiop, COLORMAP_NULL ) == -1)) return 0; (void) fb_setcursor( fbiop, arrowcursor, 16, 16, 0, 0 ); (void) fb_cursor( fbiop, 1, size/2, size/2 ); prnt_Event( (char *) NULL ); return 1; }
w3mimg_op * w3mimg_fbopen() { w3mimg_op *wop = NULL; wop = (w3mimg_op *) malloc(sizeof(w3mimg_op)); if (wop == NULL) return NULL; memset(wop, 0, sizeof(w3mimg_op)); if (!check_tty_console(getenv("W3M_TTY")) && strncmp("fbterm", getenv("TERM"), 6) != 0 && strncmp("jfbterm", getenv("TERM"), 7) != 0) { fprintf(stderr, "w3mimgdisplay/fb: tty is not console\n"); goto error; } if (fb_open()) goto error; wop->width = fb_width(); wop->height = fb_height(); wop->init = w3mfb_init; wop->finish = w3mfb_finish; wop->active = w3mfb_active; wop->set_background = w3mfb_set_background; wop->sync = w3mfb_sync; wop->close = w3mfb_close; wop->clear = w3mfb_clear; wop->load_image = w3mfb_load_image; wop->show_image = w3mfb_show_image; wop->free_image = w3mfb_free_image; wop->get_image_size = w3mfb_get_image_size; /* XXX */ fb_image_init(); return wop; error: free(wop); return NULL; }
int main(int argc, char* argv[]) { framebuffer_t* fb; img32_t* img; // check for proper usage if(argc == 1) { fprintf(stderr, "Usage: %s lena.ppm\n", argv[0]); return EX_USAGE; } // initialize the framebuffer (with single buffering) fprintf(stderr, "Starting up...\n"); if((fb = fb_open(0x11e, 0, 0)) == NULL) { perror("fb_open"); return EX_UNAVAILABLE; } // clear the screen in a shade of blue cls(fb, 0x00007F); // pause getc(stdin); // load the image img = read_ppm(argv[1]); // clear the screen in a shade of red cls(fb, 0x7F0000); // display the image centered blit(fb, img, fb->info.vi_width / 2 - img->w / 2, fb->info.vi_height / 2 - img->h / 2); // free the image free(img); // pause for dramatic effect... getc(stdin); // tidy up fprintf(stderr, "Shutting down...\n"); fb_close(fb); return EX_OK; }
int main(int argc, char **argv) { int x, y; int xin, yin; /* number of sceen output lines */ height = width = 512; /* Defaults */ if ( !get_args( argc, argv ) ) { (void)fputs(usage, stderr); bu_exit( 1, NULL ); } /* Open Display Device */ if ((fbp = fb_open(framebuffer, width, height )) == NULL ) { fprintf( stderr, "fb_open failed\n"); bu_exit( 1, NULL ); } /* determine "reasonable" behavior */ xin = fb_getwidth(fbp) - scr_xoff; if ( xin < 0 ) xin = 0; if ( xin > width ) xin = width; yin = fb_getheight(fbp) - scr_yoff; if ( yin < 0 ) yin = 0; if ( yin > height ) yin = height; for ( y = scr_yoff; y < scr_yoff + yin; y++ ) { if ( inverse ) { (void)fb_read( fbp, scr_xoff, fb_getheight(fbp)-1-y, inbuf, xin ); } else { (void)fb_read( fbp, scr_xoff, y, inbuf, xin ); } for ( x = 0; x < xin; x++ ) { obuf[x] = (((int)inbuf[3*x+RED]) + ((int)inbuf[3*x+GRN]) + ((int)inbuf[3*x+BLU])) / 3; } fwrite( &obuf[0], sizeof( char ), xin, outfp ); } fb_close( fbp ); bu_exit( 0, NULL ); }
/* Must be called after gridInit() so that gridsz is setup. */ int openFbDevice(char *fbdev) { int ret = 1; notify("Opening frame buffer", NOTIFY_APPEND); if (zoom < 1) { prntScr("Device is too small to display image."); ret = 0; goto safe_exit; } if (((fbiop != FBIO_NULL && fb_getwidth(fbiop) != devwid) || pixgrid == NULL) && (pixgrid = (unsigned char *) calloc(devwid*3, sizeof(unsigned char))) == (unsigned char *) NULL) { prntScr("Memory allocation of %d bytes failed.", sizeof(unsigned char)*devwid); ret = 0; goto safe_exit; } (void) memset((char *) pixgrid, NUL, sizeof(unsigned char)*devwid*3); if (fbiop != FBIO_NULL) { if (! closFbDevice()) { ret = 0; goto safe_exit; } } fbiop = fb_open(fbdev, devwid, devhgt); if (fbiop == NULL) { ret = 0; goto safe_exit; } else if (fb_clear(fbiop, pixblack) == -1 || (notify("Zooming", NOTIFY_APPEND), fb_zoom(fbiop, 1, 1) == -1) || (notify("Windowing", NOTIFY_DELETE), fb_window(fbiop, devwid/2, devhgt/2) == -1) ) { ret = 0; goto safe_exit; } safe_exit : notify(NULL, NOTIFY_DELETE); return ret; }
int main(int argc, char **argv) { struct fb fb; uint32_t word; void *mem; int fd; char *p; uint32_t i; int rv; if (argc != 3) return -1; word = strtoul(argv[2], &p, 16); if (*p != '\0') { fprintf(stderr, "Invalid value.\n"); exit(EXIT_FAILURE); } rv = fb_open(argv[1], &fb); if (rv) { fprintf(stderr, "Failed to open framebuffer device.\n"); exit(EXIT_FAILURE); } fprintf(stderr, "Word: 0x%x, Bpp_byte: 0x%u.\n", word, fb.bpp_byte); mem = fb.mem; for (i = 0; i < fb.mem_size; i += fb.bpp_byte) { memcpy(mem, &word, fb.bpp_byte); mem += fb.bpp_byte; } fb_close(&fb); return 0; }
int main(void) { int ret; ret = fb_open(); if (ret != 0) { fprintf(stderr, "fb_open() error.\n"); exit(1); } //srand(getpid()); //r = rand() % 10; //printf("x=%d, y=%d, rand=%d\n",xres(),yres(),r); clear(0,yres()); move(); fb_close(); return 0; }
int main(int argc, char **argv) { struct fb fb; int rv; if (argc != 2) return -1; rv = fb_open(argv[1], &fb); if (rv) { exit(EXIT_FAILURE); } display_h_color_bar(fb.mem, fb.w, fb.h, fb.bpp); fb_close(&fb); return 0; }
int main(int argc, char **argv) { int n; if ( argc > 1 ) { if ( (fp = fopen(argv[1], "r")) == NULL ) { fprintf( stderr, "%s", Usage ); bu_exit(1, "pixhist3d: can't open \"%s\"\n", argv[1] ); } } else fp = stdin; if ( isatty(fileno(fp)) ) { bu_exit(2, "%s", Usage ); } if ( (fbp = fb_open( NULL, 512, 512 )) == NULL ) { bu_exit(12, "fb_open failed\n"); } while ( (n = fread(&ibuf[0], sizeof(*ibuf), sizeof(ibuf), fp)) > 0 ) { register unsigned char *bp; register int i; bp = &ibuf[0]; for ( i = n/3; i > 0; i--, bp += 3 ) { rxb[ bp[RED] ][ bp[BLU] ]++; rxg[ bp[RED] ][ bp[GRN] ]++; bxg[ bp[BLU] ][ bp[GRN] ]++; } } disp_array( rxg, 0, 0 ); disp_array( rxb, 256, 0 ); disp_array( bxg, 0, 256 ); fb_close( fbp ); return 0; }
int main(void) { int ret; ret = fb_open(); if (ret != 0) { fprintf(stderr, "fb_open() error.\n"); exit(1); } init(); while (1) { move(); change_dir(); usleep(30000); } fb_close(); return 0; }
int main(void) { FBDEV fb; memset(&fb, 0, sizeof(FBDEV)); strcpy(fb.dev, "/dev/fb0"); if(fb_open(&fb) == FALSE) { printf("open frame buffer error\n"); return 0; } sleep(1); clear_screen(&fb); POINT p1, p2, p3; p1.x = 100; p1.y = 250; p2.x = 200; p2.y = 300; draw_line(&fb, p1, p2, 0x0, 0xff, 0x0); sleep(1); clear_screen(&fb); POINT center = { 100, 100, 0 }; int radius = 30; draw_circle(&fb, center, radius, 0x0, 0xff, 0x0); sleep(1); clear_screen(&fb); int i; for(i = radius - 2; i >= 0; i--) { draw_circle(&fb, center, i, 0x30, 0x20, 0x0); } sleep(1); clear_screen(&fb); ShowChinese(NULL); printf("o999999999999999999999\n"); sleep(1); fb_close(&fb); return 0; }