unofficial-rtos-docs

Chapter 11: Resource Project File

A resource project is an XML file that records the properties of one or more font/pixelmap resources. This XML file serves as a means to transfer resource data over the Internet. Additionally, the resource XML file can be converted to a standalone binary file through the GUIX Studio command line. After loading the standalone binary file into the RAM, you can utilize the GUIX APIs gx_binres_font_load and gx_binres_pixelmap_load to load the specific resource from the RAM buffer, making the desired resources available for use within your application.

Resource Project File Format

The resource project contains three main elements: header, display_info and resource, as show below:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE GUIX_Studio_Resource>
<resource_project>
    <!-- header element -->
    <header>
        <!-- header properties and configurations -->
    </header>

    <!-- display_info element -->
    <display_info>
        <!-- display information and settings -->
    </display_info>

    <!-- resource element -->
    <resource>
        <!-- font or pixelmap resource definitions -->
    </resource>
</resource_project>

Element: header

The header element records the essential information about the resource. It includes various properties that help manage and ensure compatibility during the conversion and the utilization of the converted resource in the GUIX System. The following code shows an example snippet of the header element.

<header> 
    <name>pixelmap</name>
    <version>56</version>
    <converter>GUIX Studio</converter>
    <studio_version>603000</studio_version>
    <guix_version>60300</guix_version>
    <target_cpu>Generic</target_cpu>
    <target_tools>Generic</target_tools>
    <dave2d_graph_accelerator>FALSE</dave2d_graph_accelerator>
</header>

Tags

Element: display_info

The display_info element contains important information about the display where the resource is intended to be presented. It ensures that the resource is appropriately generated and compatible with the intended display. The following code shows an example snippet of display_info element:

<display_info>
    <display_color_format>GX_COLOR_FORMAT_8BIT_PALETTE</display_color_format>
    <rotation_angle>0</rotation_angle>
    <total_size>256</total_size>
    <palette>
        <rgb>4278190080</rgb>
        <rgb>4279308561</rgb>
        <rgb>4280427042</rgb>
        ...
    </palette>
</display_info>

Tags

Element: resource

The following code shows an example snippet of the common elements for the resource element:

<resource>
    <type>PIXELMAP</type>
    <name>ALPHA_565RGB</name>
    <pathinfo>
        <pathname>..\common_resources\graphics\black_pause.png</pathname>
        <pathtype>project_relative</pathtype>
    </pathinfo>
</resource>

Tags

Pixelmap resource

The following code shows an example snippet of pixelmap resource element.

<resource>
    <type>PIXELMAP</type>
    <name>ALPHA_565RGB</name>
    <pathinfo>
        <pathname>..\common_resources\graphics\black_pause.png</pathname>
        <pathtype>project_relative</pathtype>
    </pathinfo>
    <compress>FALSE</compress>
    <alpha>TRUE</alpha>
    <dither>FALSE</dither>
    <raw>FALSE</raw>
    <color_format>GX_COLOR_FORMAT_565RGB</color_format>
    <palette_type>None</palette_type>
<resource>

Tags

Font resource

The following code shows an example snippet of font resource element.

<resource>
    <type>FONT</type>
    <name>FONT_8BPP</name>
    <pathinfo>
        <pathname>..\..\fonts\verasans\Vera.ttf</pathname>
        <pathtype>project_relative</pathtype>
    </pathinfo>
    <compress>FALSE</compress>
    <height>20</height>
    <font_bits>8</font_bits>
    <font_kerning>FALSE</font_kerning>
    <font_page_data>
        <first_char>32</first_char>
        <last_char>126</last_char>
    </font_page_data>
</resource>

Tags

Create Resource XML File

There are two methods available for creating XML files:

Using GUIX Studio Project: To create an XML file through GUIX Studio, follow these steps:

Manual Method: Alternatively, you can manually create a resource XML file following the formats outlined earlier.

Convert an XML File into Standalone Binary File

Below is an example of how to generate a binary resource file from a resource project using GUIX Studio’s command line.

guix_studio.exe -x xml_file_pathname -b

In this command, the -x option is used to specify the input resource XML file. The -b option indicates to produce a binary resource file rather than a C file. Executing the provided command generates an independent binary file based on the provided resource XML file.

For a more comprehensive understanding of the GUIX Studio command line, please refer to Chapter 9: GUIX Studio Command Line.