What format does “adb screencap /sdcard/screenshot.raw” produce? (without “-p” flag)

后端 未结 3 1847
悲哀的现实
悲哀的现实 2021-02-09 05:54

I am looking to use adb screencap utility without the -p flag. I imagined output will be dumped in raw format, but doesn\'t look like it. My attempts o

3条回答
  •  失恋的感觉
    2021-02-09 06:24

    Format:

    • 4 bytes as uint32 - width
    • 4 bytes as uint32 - height
    • 4 bytes as uint32 - pixel format
    • (width * heigth * bytespp) bytes as byte array - image data, where bytespp is bytes per pixels and depend on pixel format. Usually bytespp is 4.

    Info from source code of screencap.

    For your example:

    00000000  d0 02 00 00 00 05 00 00  01 00 00 00 1e 1e 1e ff
    
    • d0 02 00 00 - width - uint32 0x000002d0 = 720
    • 00 05 00 00 - height - uint32 0x00000500 = 1280
    • 01 00 00 00 - pixel format - uint32 0x00000001 = 1 = PixelFormat.RGBA_8888 => bytespp = 4 => RGBA
    • 1e 1e 1e ff - first pixel data - R = 0x1e; G = 0x1e; B = 0x1e; A = 0xff;

    Pixels with data stored in array of bytes with size 720*1280*4.

提交回复
热议问题