| | 1 | [wiki:Component SocLib Components General Index] |
| | 2 | |
| | 3 | = Component description = |
| | 4 | |
| | 5 | This component is a common utility component. |
| | 6 | |
| | 7 | This creates a frame buffer, it uses soclib-fb from the utilities for a SDL-based viewer window. |
| | 8 | |
| | 9 | For now, the only supported mode is YUV-422. This may change in the future. |
| | 10 | |
| | 11 | User may directly modify a shared-memory buffer, and update it to screen on-demand. |
| | 12 | |
| | 13 | = Component usage = |
| | 14 | |
| | 15 | == Object == |
| | 16 | |
| | 17 | {{{ |
| | 18 | soclib::common::FbController *fb; |
| | 19 | }}} |
| | 20 | |
| | 21 | == Instanciation == |
| | 22 | |
| | 23 | {{{ |
| | 24 | soclib::common::FbController( |
| | 25 | const std::string &basename, |
| | 26 | unsigned long width, |
| | 27 | unsigned long height); |
| | 28 | }}} |
| | 29 | |
| | 30 | basename:: |
| | 31 | The name of the created framebuffer window |
| | 32 | width:: |
| | 33 | Width of the window |
| | 34 | height:: |
| | 35 | Height of the window |
| | 36 | |
| | 37 | == Usage == |
| | 38 | |
| | 39 | {{{ |
| | 40 | const unsigned long width = 320; |
| | 41 | const unsigned long height = 240; |
| | 42 | |
| | 43 | soclib::common::FbController fb("fb0", width, height); |
| | 44 | |
| | 45 | ... |
| | 46 | |
| | 47 | // sample setter function: |
| | 48 | |
| | 49 | void set(soclib::common::FbController &fb, int line, int column, uint8_t y, uint8_t u, uint8_t v) |
| | 50 | { |
| | 51 | uint8_t* buffer = (uint8_t*)fb.surface(); |
| | 52 | const unsigned long width = fb.m_width; |
| | 53 | const unsigned long height = fb.m_height; |
| | 54 | |
| | 55 | buffer[ line*width +column ] = y; |
| | 56 | buffer[width*height +line*width/2+column/2] = u; |
| | 57 | buffer[width*height*3/2+line*width/2+column/2] = v; |
| | 58 | |
| | 59 | fb->update(); |
| | 60 | } |
| | 61 | }}} |
| | 62 | |