clinux-device-driverframebufferandroid-ndk-r7bpp

How to programmatically determine bpp and pixel color format of android screen?


I am trying to stream compressed raw framebuffer data to my Client application on the PC, from my Server service on Android. On the PC I want to display this raw data as streamed video in my Client's view, giving real-time view of the Android device's screen. I know how to get the resolution of the screen, but not the Bits-Per-Pixel(BPP) nor the Pixel's Color Format of the raw data programmatically at Android(Server) side. Please help.

All I could find over the Internet is native code. But I really wish to maintain the application as Java defined as possible.

From FBIOGET_VSCREENINFO over ioctl get BPP(bits-per-pixel) as follows

int main () {
    int fbfd;
    struct fb_var_screeninfo variable_info;

    fbfd=open("/dev/fb0", O_RDWR);
    //in real life, check every ioctl if it returns -1

    ioctl (fbfd, FBIOGET_VSCREENINFO, &variable_info);

    //This is the required BPP value
    switch(variable_info.bits_per_pixel) {
        case 16: //pixel format is RGB_565
            break;
        case 24: //pixel format is RGB_888
            break;
        case 32: //pixel format is RGBX_8888
            break;
    }
}

Solution

  • Finally figured out how to determine

    References :-