0% found this document useful (0 votes)
41 views

OSD Resource Introduction

Uploaded by

gongjinjun10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

OSD Resource Introduction

Uploaded by

gongjinjun10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 13

OSD Resource Introduction

1.0

2006-11-9

THIS DOCUMENT CONTAINS PROPRIETARY TECHNICAL INFORMATION WHICH IS THE PROPERTY


OF ALI CORPORATION AND SHALL NOT BE DISCLOSED TO OTHERS IN WHOLE OR IN PART,
REPRODUCED, COPIED, OR USED AS THE BASIS FOR DESIGN, MANUFACTURING, OR SALE OF
APPARATUS WITHOUT WRITTEN PERMISSION OF ALI CORPORATION

OSD Resource Introduction


Change History

Revision Issue Date Comments


1.0 2006-11-9 First release

OSD Resource Introduction


Contents
1 Introduction.................................................................................................................................................................1
2 Bitmaps........................................................................................................................................................................1
2.1 Bitmap Data Format.......................................................................................................................................1
2.2 Bitmap Data Generating................................................................................................................................2
3 Fonts............................................................................................................................................................................3
3.1 Font Data Format...........................................................................................................................................3
3.2 Font Data Generating....................................................................................................................................4
4 String............................................................................................................................................................................5
4.1 String Data Format.........................................................................................................................................5
4.2 String Data Generating..................................................................................................................................5
5 Palette..........................................................................................................................................................................5
5.1 Palette Data Format.......................................................................................................................................5
5.2 Palette Data Generating................................................................................................................................6
6 WINSTYLE..................................................................................................................................................................6
6.1 WINSTYLE Data Format...............................................................................................................................6
6.2 WINSTYLE Data Generating......................................................................................................................10

OSD Resource Introduction


1 Introduction
OSD resource includes fonts, strings, bitmaps, palette and WINSTYL data. The WINSLYTE is the
abstraction of the color and pattern to draw the GUI objects or rectangles. The reference code has a file
name osd_rsc.c, the file include all resource file, APIs to access the resource data (called by OSD
library).

2 Bitmaps

2.1 Bitmap Data Format


There is an array with the following format to describe each bitmap’s information.

typedef struct
{
unsigned short w;
unsigned short h;
unsigned long bmp_size;
unsigned long data_size;
const unsigned char* data;
}bitmap_infor_t;
w
icon’s width
h
icon’s height
bmp_size
icon’s data size before compressed
data_size
icon’s data size after compressed
data
icon’s data (compressed with RLE)

A flag byte is at each start of the coding segment.

bit 7 bit 6 … bit 0

bit7 - flag of the following byte(s)


- 0 the icon has same data of the following byte with length of bit6-bit0 (1 - 127)
- 1 the icon has a data of the following bytes with length of bit6-bit0 (1 - 127)
bit6…bit0 - data length of same byte (bit7=0) or different data length (bit7=1)
When bit7 is 0, then the next flag byte is the one byte later.
When bit7 is 1, then the next flag byte is the after the number decided by bit6…bit0

The following is an example of bitmap data array:

OSD Resource Introduction 1


2.2 Bitmap Data Generating
The tool in our ALI SDK disc: \Tools\OSD Generate Tool\bmptobin.exe is used to convert bitmap files to
OSD library accessible format.
When use the tool, put all the bitmaps files and the tool (bmptobin.exe) at the same directory and run the
tool (e.g. double click it). The tool will search all the bitmaps file under current directory, and generate
many header file and each for one bitmap file plus bitmaps_array.h and images.id. Then you can copy
all the header files (including bitmaps_array.h) to your project’s resource file directory without any
change, copy images.id to UI files’ directory (this file will used by UI files).
For the demo code, copy all the header files (including bitmaps_array.h) to Glass_DemoBoard \ rsc \
bmp. Copy images.id to Glass_DemoBoard\.

Note:
1. Please remove bitmap files that not for the project.
2. In osd_rsc.c, the array of font_bitmap[ ] is used to hold the bitmap and the font’s data when access
it. So you should guarantee the size of font_bitmap[ ] should equal or larger the bitmaps’ max
bmp_size.

OSD Resource Introduction 2


3 Fonts

3.1 Font Data Format


Each types of font have information with following format:

typedef struct
{
UINT8 height;
UINT16 uFontCnt;
const UINT8* width;
const UINT32* data;
const UINT16* uIdxTab;
} font_t;

height
font’s height
uFontCnt
font’s count
width
font’s width array for every character
data
font’s data array for every character
uIdxTab
font’s character code(unicode) array

If a character’s with value is 0, it means that that character not coded in this font, at the same time no
font data in the font data array.
A character’s font data’s is illustrated in the following figure.

Figue-1 character’s font data format

Every character’s font data must be multiple of 32-bit. If need, some padding bits maybe added to fit this
limitation.
Each kind of font may have different size, so a font array is used to descript different size fonts of same
kind. In application may has different kind of fonts, and then another font array is used to descript
different kind of fonts.

The following is an example of different size of ASCII character fonts.

font_t font_asc[] =

OSD Resource Introduction 3


{
22, 95, Fonts_asc_width, Fonts_asc_data, Fonts_asc_name,
22, 95, Fonts_asc_width, Fonts_asc_data, Fonts_asc_name,
30, 11, Fonts_09big_width, Fonts_09big_data, Fonts_09big_name,
22, 95, Fonts_asc_width, Fonts_asc_data, Fonts_asc_name,
};

3.2 Font Data Generating


The tool in our ALI SDK disc: \Tools\OSD Generate Tool\generateFontData.exe is used to generate font
data.
When use generating the font data, put the entire font’s bitmaps files and the tool
(generateFontData.exe) to the same directory, run the tool (e.g. double click it), then a file name
Font_CHN.h is created.
This file contain three array: const short Fonts_name[xxx], const UINT8 Fonts_width[ ] and const
UINT32 Fonts_data[ ].
The const short Fonts_name[xxx] is the font bitmaps’ corresponding characters’s UNICODE data.
The const UINT8 Fonts_width[ ] is the each character’s width.
The const UINT32 Fonts_data[ ] is font’s bitmap data .
For the font’s height is the the font bitmap’s height. The xxx in const short Fonts_name[xxx] give the font
count.
You need to rename the Font_CHN.h to the proper font name. Also the const short Fonts_name[xxx],
const UINT8 Fonts_width[ ] and const UINT32 Fonts_data[ ] need to rename to a proper name to
distinguish it from the other font’s data.
For the demo code, copy the font data to Glass_DemoBoard \ rsc \ font.

Note:
1. You can only generating one font with the same height at one time. That’s you should not mix font
bitmaps with different height to generate the font data. For the same characters with different font’s
height, generate the font’s data for one height individually.
2. You should well understand the functions of OSD_GetDefaultFontLib() and get_font() in osd_rsc.c for
the information of how the OSD library access a character’s font data and how to add new font support.

OSD Resource Introduction 4


4 String

4.1 String Data Format


UNICODE is used to code characters of stings. Each kind of string ( each language) data array has
following format.

BYTE Meaning

0 Byte number use for coding each character(=2)

1~2 String number ( (byte1 << 8) + byte2 ) = N

3~4 1st string data offset from the start of the string data array

5~6 2nd string data offset from the start of the string data array

3 + i*2 ~ 3 + i*2 + 1 Sting i data offset from the start of the string data array

… ..
3 + N*2 ~ 3 + N*2 +
Last string data offset from the start of the string data array
1
…… Character UINCODE data of every string

4.2 String Data Generating


The tool in our ALI SDK disc: \Tools\OSD Generate Tool\exceluistrou.exe is used to generating string
data.
Generally there is a multi-langue string excel file. The first column is the string ID list; the other columns
are strings for each language. The first row is the language name beside the first column item is “id”.
The second row needs to set “2” for each column. From the third, the first column is the string ID name;
the other columns are the translated string for each language.
When generating the string data, first open the excel file and same it as “Unicode txt” format. Then open
it will notepad and remove double quotation mark by replace it with nothing). After the processing, it is
ready to use the tool to generating string data.
Tool usage: exceluistrou.exe [filename]. Here if you don’t specify the txt file, it will search string.txt
and strings.txt to process. Then some files generate, including str_xxx.h and string.id. Here xxx
represent the language name.
For the demo code, copy str_xxx.h to Glass_DemoBoard \ rsc \ str, copy string.id to Glass_DemoBoard\.

Note:
1. You should well understand function OSD_SetLangEnvironment(), g_LangRscMapTable array
and LANG_GROUP_t in osd_rsc.c, string_array.h and osd_rsc.h to add new language support.

5 Palette

5.1 Palette Data Format


Palette’s entry is coded in YUV with alpha, the palette data’s format is:

OSD Resource Introduction 5


unsigned char palette[][4] =
{
{Y0, U0, V0, a1},
{Y1, U1, V1, a2},
{Y2, U2, V2, a3},
{Y3, U5, V3, a4},
……
{Y255, U255, V255, a255},
};
When a1-a255 is the OSD alpha of each color, it value range is between 0 and 15.
When the value is 0 means the corresponding color is transparent, when the value is 15 means it is
opaque, the value between 1 and 14 means the color is translucent.

5.2 Palette Data Generating


The tool in our ALI SDK disc: \Tools\OSD Generate Tool\genpallete.exe is used to generating palette
data.
A UI design will provide palette bitmap file. For 256 color UI design, the palette looks like the follow
picture. Its size is 256X256.

Tool usage: genpallete.exe [palette file] [256]. It will generate a palette file with name same as palette
file but the file extension is “.h”. If it runs with no arguments specified, then it will try to file palette.bmp to
processing and output palette.h. The output palette file include two palette arrays: one is RGB style the
other is YUV style. Select YUV to use. The generate palette array’s color alpha value is 0xFF; it should
change to the value between 0 and 15 according to UI design. Then copy the YUV palette array to
renamed palette file.
For the demo code, copy the modified YUV palette file to Glass_DemoBoard \ rsc \ pal.

6 WINSTYLE
WINSTYLE is the abstraction of the pattern and color to draw an object or a frame.

6.1 WINSTYLE Data Format


typedef struct {
WSTYLE_TYPE bWinStyleType;

OSD Resource Introduction 6


UINT16 wTopLineIdx;
UINT16 wLeftLineIdx
UINT16 wRightLineIdx;
UINT16 wBottomLineIdx;
UINT16 wBgIdx;
UINT16 wFgIdx;

UINT16 wLeftTopIdx;
UINT16 wLeftButtomIdx;
UINT16 wRightTopIdx;
UINT16 wRightButtomIdx;
UINT16 IconLibIdx;
} WINSTYLE, *PWINSTYLE;

There are three types of WINSTYLE.


typedef enum{
C_WS_LINE_DRAW,
C_WS_LINE_CIRCL_DRAW,
C_WS_PIC_DRAW,
C_WS_USER_DEFINE
} WSTYLE_TYPE;

The type of C_WS_LINE_DRAW means draw a rectangle frame with specified board color, background
color and foreground color. The type of C_WS_LINE_CIRCL_DRAW is same as C_WS_LINE_DRAW
except that it’s a circle rectangle. The type of C_WS_PIC_DRAW means draw a rectangle with frame
with bitmaps.

Field Means Means Means


C_WS_LINE_CIRCL_D
bWinStyleType C_WS_LINE_DRAW C_WS_PIC_DRAW
RAW

wTopLineIdx The top line’s color The top line’s color The top line’s bitmap ID

wLeftLineIdx The left line’s color The left line’s color The left line’s bitmap ID

The right line’s bitmap


wRightLineIdx The right line’s color The right line’s color
ID
The bottom line’s
wBottomLineIdx The bottom line’s color The bottom line’s color
bitmap ID
wBgIdx Background color Background color Background color
wFgIdx Foreground color Foreground color Foreground color

wLeftTopIdx N/A N/A The left top’s bitmap ID

The right top’s bitmap


wLeftButtomIdx N/A N/A
ID

wRightTopIdx N/A N/A The left top’s bitmap ID

wRightButtomIdx N/A N/A The left top’s bitmap ID

IconLibIdx N/A N/A LIB_ICON

OSD Resource Introduction 7


There are some flags can be set to color field, including C_NOSHOW, C_MIXER, C_DOUBLE_LINE.
Also for bitmap ID, INVALID_INDEX is used to describe that no bitmap is used.

Field Possible flags Possible flags Possible flags or setting

C_WS_LINE_CIRCL_D
bWinStyleType C_WS_LINE_DRAW C_WS_PIC_DRAW
RAW
C_NOSHOW/ C_NOSHOW/
wTopLineIdx INVALID_INDEX
C_DOUBLE_LINE C_DOUBLE_LINE
C_NOSHOW/ C_NOSHOW/
wLeftLineIdx INVALID_INDEX
C_DOUBLE_LINE C_DOUBLE_LINE
C_NOSHOW/ C_NOSHOW/
wRightLineIdx INVALID_INDEX
C_DOUBLE_LINE C_DOUBLE_LINE
C_NOSHOW/ C_NOSHOW/ The bottom line’s
wBottomLineIdx
C_DOUBLE_LINE C_DOUBLE_LINE bitmap ID
C_NOSHOW| C_NOSHOW|
wBgIdx NOSHOW | C_MIXER
C_MIXER C_ C_MIXER
wFgIdx C_MIXER C_MIXER C_MIXER
wLeftTopIdx N/A N/A INVALID_INDEX
wLeftButtomIdx N/A N/A INVALID_INDEX
wRightTopIdx N/A N/A INVALID_INDEX
wRightButtomIdx N/A N/A INVALID_INDEX
IconLibIdx N/A N/A LIB_ICON

There following figures illustrate three types of WINSTYLE.

OSD Resource Introduction 8


OSD Resource Introduction 9
6.2 WINSTYLE Data Generating
The WINSTYLE data is edit manually without tools. Generally UI designer will provide a PowerPoint file
to describe the WINSTYLES that used in a UI project.

OSD Resource Introduction 10

You might also like