项目作者: afrantzis

项目描述 :
Pixel Format Guide
高级语言: Python
项目地址: git://github.com/afrantzis/pixel-format-guide.git
创建时间: 2017-09-04T16:27:17Z
项目社区:https://github.com/afrantzis/pixel-format-guide

开源协议:GNU Lesser General Public License v2.1

下载


Welcome to the Pixel Format Guide Tool

The Pixel Format Guide Tool is a python program that describes how the
components of various pixels formats are laid out in memory.

This tool is part of the Pixel Format Guide.

Development of the Pixel Format Guide is sponsored by Collabora Ltd.

How to run the Pixel Format Guide Tool

Run with:

  1. $ python3 -m pfg describe [OPTIONS...] [FORMAT]
  2. $ python3 -m pfg find-compatible [OPTIONS...] [FORMAT] [FAMILY]
  3. $ python3 -m pfg document [FAMILY]
  4. $ python3 -m pfg list-families
  5. $ python3 -m pfg list-formats [FAMILY]

Examples of using the describe command:

  1. $ python3 -m pfg describe GL_RGBA+GL_UNSIGNED_INT_2_10_10_10_REV
  2. Format: GL_RGBA+GL_UNSIGNED_INT_2_10_10_10_REV
  3. Component data type: UNORM
  4. Described as: Native 32-bit type
  5. Native type: M L
  6. AABBBBBBBBBBGGGGGGGGGGRRRRRRRRRR
  7. Memory little-endian: 0 1 2 3
  8. M L M L M L M L
  9. RRRRRRRR GGGGGGRR BBBBGGGG AABBBBBB
  10. Memory big-endian: 0 1 2 3
  11. M L M L M L M L
  12. AABBBBBB BBBBGGGG GGGGGGRR RRRRRRRR
  13. $ python3 -m pfg describe VK_FORMAT_A2R10G10B10_SINT_PACK32
  14. Format: VK_FORMAT_A2R10G10B10_SINT_PACK32
  15. Component data type: SINT
  16. Described as: Native 32-bit type
  17. Native type: M L
  18. AARRRRRRRRRRGGGGGGGGGGBBBBBBBBBB
  19. Memory little-endian: 0 1 2 3
  20. M L M L M L M L
  21. BBBBBBBB GGGGGGBB RRRRGGGG AARRRRRR
  22. Memory big-endian: 0 1 2 3
  23. M L M L M L M L
  24. AARRRRRR RRRRGGGG GGGGGGBB BBBBBBBB
  25. $ python3 -m pfg describe WL_DRM_FORMAT_ARGB8888
  26. Format: WL_DRM_FORMAT_ARGB8888
  27. Component data type: UNORM
  28. Described as: Bytes in memory
  29. Memory little-endian: 0 1 2 3
  30. M L M L M L M L
  31. BBBBBBBB GGGGGGGG RRRRRRRR AAAAAAAA
  32. Memory big-endian: 0 1 2 3
  33. M L M L M L M L
  34. BBBBBBBB GGGGGGGG RRRRRRRR AAAAAAAA
  35. $ python3 -m pfg describe --hide-bit-indices SDL_PIXELFORMAT_RGB565
  36. Format: SDL_PIXELFORMAT_RGB565
  37. Component data type: UNORM
  38. Described as: Native 16-bit type
  39. Native type: M L
  40. RRRRRGGGGGGBBBBB
  41. Memory little-endian: 0 0
  42. M L M L
  43. GGGBBBBB RRRRRGGG
  44. Memory big-endian: 0 0
  45. M L M L
  46. RRRRRGGG GGGBBBBB

Examples of using the find-compatible command:

  1. $ python3 -m pfg find-compatible VK_FORMAT_R8G8B8A8_UNORM sdl2
  2. Format: VK_FORMAT_R8G8B8A8_UNORM
  3. Is compatible on all systems with:
  4. SDL_PIXELFORMAT_RGBA32
  5. Is compatible on little-endian systems with:
  6. SDL_PIXELFORMAT_ABGR8888
  7. Is compatible on big-endian systems with:
  8. SDL_PIXELFORMAT_RGBA8888
  9. $ python3 -m pfg find-compatible GL_RGB+GL_UNSIGNED_SHORT_5_6_5_REV pixman
  10. Format: GL_RGB+GL_UNSIGNED_SHORT_5_6_5_REV
  11. Is compatible on all systems with:
  12. PIXMAN_b5g6r5
  13. Is compatible on little-endian systems with:
  14. Is compatible on big-endian systems with:
  15. $ python3 -m pfg find-compatible --treat-x-as-a PIXMAN_x8r8g8b8 wayland_drm
  16. Format: PIXMAN_x8r8g8b8
  17. Is compatible on all systems with:
  18. Is compatible on little-endian systems with:
  19. WL_DRM_FORMAT_XRGB8888
  20. WL_DRM_FORMAT_ARGB8888
  21. Is compatible on big-endian systems with:
  22. WL_DRM_FORMAT_BGRX8888
  23. WL_DRM_FORMAT_BGRA8888

Examples of using the document command:

  1. $ python3 -m pfg document vulkan
  2. # Vulkan pixel formats
  3. ...
  4. $ python3 -m pfg document wayland_drm
  5. # Wayland-drm pixel formats
  6. ...

Examples of using the list-families command:

  1. $ python3 -m pfg list-families
  2. cairo
  3. opengl
  4. pixman
  5. ...

Examples of using the list-formats command:

  1. $ python3 -m pfg list-formats cairo
  2. CAIRO_FORMAT_ARGB32
  3. CAIRO_FORMAT_RGB24
  4. ...

Contributing to the Pixel Format Guide Tool

To add support for a new pixel format family (let’s call it family), do the
following:

  • Add some tests for typical pixel formats definitions in the family
    in tests/test_family.py. Use one of the existing test files as a
    template.

  • Implement the describe method in a new pfg/family.py file. Use one of the
    existing files as a template.

  • Implement the formats method in the pfg/family.py file. Use one of the
    existing files as a template.

  • Implement the document method in the pfg/family.py file, by creating a
    docs/family.md and returning its contents (use the
    util.read_documentation helper).

  • Import the family module and add it to the list of families in
    pfg/commands.py.

  • Add a link to the new family document file in docs/index.md.

  • Run python3 -m unittest discover and ensure all tests pass.