Working with Embedded Wizard: Managing resources and assets
In practice, every GUI application requires image and font data to be displayed at the runtime on the screen. This chapter introduces the corresponding concepts of resources and constants.
Bitmap resources
Images (or image assets) are represented in Embedded Wizard by bitmap resource project members. In practice, for every image you intend to use within your GUI application you have to add and configure one bitmap resource member. In a more sophisticated case you can manage with a single bitmap resource several image frames which at runtime can be selected conveniently by using an index or, similarly to a short video sequence, can be played back. Moreover, bitmap resource members can be localized for usage in a multi-lingual application.
How bitmap resources are added, configured and localized is described in the chapter Bitmap resource. Generally, with the bitmap resource member you simply refer to an original PNG, JPG, GIF, BMP, ... file. At the code generation time, the affected file is evaluated and converted for your particular target system in the best possible manner. This includes color reduction, dithering and compression. Embedded Wizard also supports motion JPEG (MJPEG) files as source format what is ideal to add animations or short instruction videos to your application.
To display the bitmap on the screen the Mosaic framework provides various views.
Default bitmap resources
Embedded Wizard Studio provides a set of predefined bitmap resources containing icons for typical application cases. They are intended to help you when you start to create a prototype of your new product. In order to be flexibel, these default bitmap resources are available in 4 different sizes. If you like them, just select the desired bitmap resource name in the image view.
Please note, the default bitmap resources are multi-frame and they are stored in the ALPHA8 format. Thus when using them in an image view always specify the number of the desired frame as well as the color to colorize the bitmap. The following table shows the available bitmap resources. The numbers below the icons indicate the corresponding frame numbers:
Bitmap resource name |
Size |
Preview |
---|---|---|
Resources::KeyIconsSmall Resources::KeyIconsMedium Resources::KeyIconsLarge Resources::KeyIconsExtraLarge |
24x24 36x36 54x54 84x84 |
|
Resources::NavigationIconsSmall Resources::NavigationIconsMedium Resources::NavigationIconsLarge Resources::NavigationIconsExtraLarge |
24x24 36x36 54x54 84x84 |
|
Resources::PlayerIconsSmall Resources::PlayerIconsMedium Resources::PlayerIconsLarge Resources::PlayerIconsExtraLarge |
24x24 36x36 54x54 84x84 |
|
Resources::SymbolIconsSmall Resources::SymbolIconsMedium Resources::SymbolIconsLarge Resources::SymbolIconsExtraLarge |
24x24 36x36 54x54 84x84 |
If you are looking for other images not included in the above table, then you have to create the image file by yourself and add it as a new bitmap resource member to your project.
Extern Bitmap contents
With the above mentioned bitmap resources you define a static set of graphics to use in your application. In order to load image contents dynamically at the runtime (e.g. files found on a SD card) the Mosaic framework provides a simple interface you can implement to integrate your application with an external image decoder..
Once the interface is implemented, you use Extern Bitmap objects similarly as you do with ordinary bitmap resources. In particular you can assign an Extern Bitmap object to a view and thus display the image.
SVG resources (scalable vector graphics)
Starting with version 14 image assets can also be provided as SVG data files. In Embedded Wizard these are represented by SVG resource project members. In practice, for every SVG image you intend to use within your GUI application you have to add and configure one SVG resource member. SVG resource members can be localized for usage in a multi-lingual application.
How SVG resources are added, configured and localized is described in the chapter SVG resource. Generally, with the SVG resource member you simply refer to an original SVG file or you enter the SVG content as XML text directly in Embedded Wizard. At the code generation time, the affected SVG image is evaluated and converted for your particular target system in the best possible manner. This includes compression of vector data and elimination of not supported elements.
To display the SVGs on the screen the Mosaic framework provides various views.
Dynamically obtained SVG images (scalable vector graphics)
With the above mentioned SVG resources you define a static set of graphics to use in your application. In order to load SVG image contents dynamically at the runtime (e.g. files found on a SD card) the Mosaic framework provides a simple Graphics::SVG class where the SVG XML text can be assigned as simple string and processed at the runtime of the application. Objects of the Graphics::SVG class can thereupon be displayed on the screen by using the provided the views.
Font resources
Fonts are represented in Embedded Wizard by font resource project members. In practice, for every font you intend to use within your GUI application you have to add and configure a font resource member. In a more sophisticated case, you can combine with a single font resource member several real fonts to one big virtual font. The font resource member determines all attributes of the used font like its height, style, weight and specifies which font glyphs (signs) are important for your application. Knowing this, Embedded Wizard can optimize and compress the font information in the best possible manner for your target system.
How font resources are added and configured is described in the chapter Font resource. Generally, with the font resource member you simply refer to a TrueType font installed on your desktop PC. At the code generation time, the affected TrueType font is evaluated and all glyphs specified in the font resource member are rasterized in small bitmaps ready to use in your target system. In this case no TrueType font engine is required in the target device. However, if your target device contains already a TrueType font engine, we can provide you a Platform Package optimized to rasterize the glyphs directly at the runtime by using the available font engine.
To display the text on the screen the Mosaic framework provides various views.
Default font resources
Embedded Wizard Studio provides a set of predefined font resources with 4 typical sizes. They are intended to help you when you start to create a prototype of your new product. If you like them, just select the desired font resource name in the text view. The following table shows all available font resources:
Font resource name |
Used TrueType font |
Font height |
Included font glyphs |
---|---|---|---|
Resources::FontSmall |
Roboto |
18 |
0x0020..0x00FF |
Resources::FontMedium |
Roboto |
24 |
0x0020..0x00FF |
Resources::FontLarge |
Roboto |
36 |
0x0020..0x00FF |
Resources::FontExtraLarge |
Roboto |
84 |
0x0020..0x00FF |
If you are looking for other fonts not included in the above table, then you have to add a new font resource member to your project and configure it accordingly.
String constants
Strings (text) can be managed conveniently by using the constant project members. In practice, you can define for every text phrase an individual constant member, which then can be referred within your application wherever this text is needed. The constant members can be easily localized for usage in a multi-lingual application.
How constants are added, configured and localized is described in the chapter Constant. To display the text on the screen the Mosaic framework provides various views.
TIP
Embedded Wizard supports character codes (code points) from UNICODE plane 0. This includes Arabic and Hebrew scripts. Also bidirectional text (BIDI) output with left-to-right (LTR) and right-to-left (RTL) text writing direction, as well as combinations of them according to the Unicode Standard Annex #9 Unicode version 10.0.0 are supported.
Default string constants
Embedded Wizard Studio provides a set of predefined string constants containing text fragments necessary when formatting date and time outputs. These constants are used mainly by the Mosaic class Core::Time. Of course, if necessary the constants can also be used directly within your project in expressions wherever a string operand is expected. The following table shows all available constants:
Constant name |
Content |
---|---|
Resources::January Resources::February Resources::March Resources::April Resources::May Resources::June Resources::July Resources::August Resources::September Resources::October Resources::November Resources::December |
"January" "February" "March" "April" "May" "June" "July" "August" "September" "October" "November" "December" |
Resources::JanuaryAbbr Resources::FebruaryAbbr Resources::MarchAbbr Resources::AprilAbbr Resources::MayAbbr Resources::JuneAbbr Resources::JulyAbbr Resources::AugustAbbr Resources::SeptemberAbbr Resources::OctoberAbbr Resources::NovemberAbbr Resources::DecemberAbbr |
"Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec" |
Resources::Monday Resources::Tuesday Resources::Wednesday Resources::Thursday Resources::Friday Resources::Saturday Resources::Sunday |
"Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday" |
Resources::MondayAbbr Resources::TuesdayAbbr Resources::WednesdayAbbr Resources::ThursdayAbbr Resources::FridayAbbr Resources::SaturdayAbbr Resources::SundayAbbr |
"Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun" |
Resources::AM Resources::PM |
"AM" "PM" |
All constants are per default not localized. They contain only the English version of the corresponding expression. To localize the constants for other languages, create a new static variant of every affected constant and initialize it with contents localized for individual languages. In this manner the Mosaic class Core::Time will automatically use the notation valid for the actually selected language.
Other constant data
Similarly to the above described strings, you can use the constant project members to manage within your application any further information. This can for example be color, position or size settings. Even using the constant members permits you to localize this information for multi-lingual applications.
Blob files and storage location of constants and resources
Before version 14 all constants and all resources were a fixed part of the generated code. Once compiled the binary, exchanging the data was not possible. With version 14 we have introduced a new possibility to manage the constants and resources inside a Blob file. By using Blob files, the relevant contents are not belonging any more to the binary and can be exchanged. For more details see the chapter Blob files.