[<<] [<] Page 1 of 1 [>] [>>] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Playing with GrOpenClientFramebuffer
From: "Pierre TARDY" ####@####.#### Date: 27 Mar 2002 13:12:07 -0000 Message-Id: <F133BIhfs8g4RMqgryA0001197e@hotmail.com> Hello, I'm looking for porting some framebuffer app I've done to nanogui. I've a PDA, with a 4 bits per pixel framebuffer. my prg holds a false frame buffer. I want to copy this false fb to the real fb at the right place: void FlushFB() { GR_WINDOW_FB_INFO fbinfo; GR_WINDOW_INFO winfo; char *d,*s; GrGetWindowFBInfo(mainwid,&fbinfo ); GrGetWindowInfo(mainwid,&winfo ); d=(char *)fbinfo.winpixels; s=fb; printf("x = %d y = %d pitch = %d \n",winfo.x,winfo.y,fbinfo.pitch); } The printf return the same line even if I move the window. x = 3 y = 16 pitch = 320 All is false.. x,y and pitch, that should be 320/2 (4bpp) here is the initialisation stuff: void initfb() { if (GrOpen() < 0) { fprintf(stderr, "cannot open graphics\n"); exit(1); } fb2=(char *)GrOpenClientFramebuffer(); if(!fb2) printf("cannot share framebuffer!!\n"); mainwid = GrNewWindowEx(GR_WM_PROPS_APPFRAME |GR_WM_PROPS_APPWINDOW | GR_WM_PROPS_CAPTION |GR_WM_PROPS_CLOSEBOX, (GR_CHAR *)"vt100em", GR_ROOT_WINDOW_ID, 0, 0, 320, 220, WHITE); wgc = GrNewGC(); GrSetGCBackground(wgc, WHITE); GrSetGCForeground(wgc, BLACK); GrSetGCUseBackground(wgc, GR_TRUE); GrSelectEvents(mainwid, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_BUTTON_DOWN |GR_EVENT_MASK_BUTTON_UP | GR_EVENT_MASK_KEY_DOWN|GR_EVENT_MASK_CLOSE_REQ); fb = (char *) malloc(rb * 240); // the buffer is volontary too big.. /* bm = (GR_BITMAP *) malloc((rb/2) * 240); // old idea, of course very slow */ GrMapWindow(mainwid); GrReqShmCmds(655350); // is it usefull?? /* framebuf_fd = open ("/dev/fb0", O_RDWR); fb = (char *)mmap(NULL, rb * 240, PROT_READ | PROT_WRITE, MAP_SHARED, framebuf_fd, 0); */ } when I look at nanox/clientfb.c: 159 fbinfo->pitch = fbinfo->xres * fbinfo->bytespp; 164 /* winpixels only valid for non-portrait modes*/ 165 physoffset = info.y*fbinfo->pitch + info.x*fbinfo->bytespp; 166 fbinfo->winpixels = physpixels? (physpixels + physoffset): NULL; of course pitch is false, bytespp is theorically 0.5.. Is it a bug? How should I do,then ? Pierre _________________________________________________________________ Téléchargez MSN Explorer gratuitement à l'adresse http://explorer.msn.fr/intl.asp. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [nanogui] Playing with GrOpenClientFramebuffer
From: "Greg Haerr" ####@####.#### Date: 27 Mar 2002 16:43:31 -0000 Message-Id: <060501c1d5ad$963615f0$6401a8c0@gregnewport> > when I look at nanox/clientfb.c: > 159 fbinfo->pitch = fbinfo->xres * fbinfo->bytespp; > 164 /* winpixels only valid for non-portrait modes*/ > 165 physoffset = info.y*fbinfo->pitch + info.x*fbinfo->bytespp; > 166 fbinfo->winpixels = physpixels? (physpixels + physoffset): > NULL; > > of course pitch is false, bytespp is theorically 0.5.. > > Is it a bug? Yes, it looks like line 159 is written to only work with 8bpp or greater. Try changing line 159 to something like fpinfo->pitch = (fpinfo->xres+1)* 2; and then things should work. If this works, I'll change the line 159 to something more portable, that calcs pitch properly for all BPP ranges. Regards, Greg | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[<<] [<] Page 1 of 1 [>] [>>] |