2013-09-01 2 views
2

ioctl을 사용하여 프레임 버퍼에 쓰기가 잘되고 있습니다.frambuffer가 끝나면 어떻게 콘솔 테스트를 복원합니까?

그러나 이미지를 닫으면 이미지가 화면에 나타납니다. 내가 버퍼에 쓴 전에 어떻게 콘솔 텍스트를 복원하고 싶습니다. 누구든지이 작업을 수행하는 방법을 알고 있습니까? 아래 코드는 내가 사용하고있는 코드입니다.

struct fb_var_screeninfo vinfo; 


    fbfd = open("/dev/fb0", O_RDWR); 
    if (!fbfd) { 
    printf("Error: cannot open framebuffer device.\n"); 
    return(1); 
    } 

    // Get variable screen information 
    if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) { 
    printf("Error reading variable information.\n"); 
    } 
    printf("Original %dx%d, %dbpp\n", vinfo.xres, vinfo.yres, 
     vinfo.bits_per_pixel); 


    // map fb to user mem 
    screensize = finfo.smem_len; 
    fbp = (char*)mmap(0, 
       screensize, 
       PROT_READ | PROT_WRITE, 
       MAP_SHARED, 
       fbfd, 
       0); 

    if ((int)fbp == -1) { 
    printf("Failed to mmap.\n"); 
    } 
    else { 
// draw...some lines 
    int x, y; 
    unsigned int pix_offset; 

    for (y = 0; y < (vinfo.yres/2); y++) { 
     for (x = 0; x < vinfo.xres; x++) { 

     // calculate the pixel's byte offset inside the buffer 
     // see the image above in the blog... 
     pix_offset = x + y * finfo.line_length; 

     // now this is about the same as fbp[pix_offset] = value 
     *((char*)(fbp + pix_offset)) = 16 * x/vinfo.xres; 

     } 
    } 

    sleep(5); 
    } 

    // cleanup 
    munmap(fbp, screensize); 
    if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &orig_vinfo)) { 
    printf("Error re-setting variable information.\n"); 
    } 
    close(fbfd); 

    return 0; 

} 

답변

0

나는이 질문이 꽤 오래되었다는 것을 알고 있지만, 나는 (내가 한 것처럼)이 질문을 가로막는 사람에게 해결책을 제시 할 것입니다.

:

cp /dev/fb0 /tmp/orig_screen

는 내가 함께 이전 화면으로 복원 프레임 버퍼를 사용하여 수행있을 때 : 나는 보통 무엇을

는 그것을 기록하기 전에 화면의 스크린 샷을 얻을 수 있습니다

cp /tmp/orig_screen /dev/fb0

관련 문제