Optimize Images for Graphics Performance (Compact 2013)
3/26/2014
When you use more than 20 image files in a UI, or if you use image files that contain many bits and have an exceptionally large file size, images can take longer to load on the display screen. A typical image file is considered exceptionally large if it is greater than 2 KB, whereas a big image file, such as a background image, is considered exceptionally large if it is greater than 150 KB. To help images load quickly, you can optimize them for graphics performance.
Modify the File Type of Graphic Images to Optimize Load Time
Use Windows Bitmap (.bmp) images as bitmap source files in your XAML for Windows Embedded UI, to help improve load time.
For an image of the same height and width dimensions, choosing a file type for the image is a tradeoff between graphics performance and memory use.
Uncompressed image file formats such as .bmp files require more memory; however, they load much faster and can help improve graphics performance. Compressed file formats such as .jpeg are more difficult to decode and take longer to load.
Image type |
Graphic performance impact |
Memory impact |
OS design requirements |
---|---|---|---|
Joint Photographic Experts Group (JPEG) (*.jpg, *.jpeg files) |
Slowest to display at load time |
Requires less memory |
SYSGEN_IMAGING, SYSGEN_IMAGING_JPG_DECODE, SYSGEN_IMAGING_JPG_ENCODE |
Portable Network Graphic (PNG) (*.png files) |
Slow to display at load time |
Requires less memory |
SYSGEN_IMAGING, SYSGEN_IMAGING_PNG_DECODE, SYSGEN_IMAGING_PNG_ENCODE |
Windows Bitmap (*.bmp files |
Fastest to display at load time |
Requires more memory |
SYSGEN_IMAGING, SYSGEN_IMAGING_BMP_DECODE, SYSGEN_IMAGING_BMP_ENCODE |
Load Images from Resource Binaries
Images with exceptionally large file sizes can require lots of system memory and can affect graphics performance. Exceptionally large file sizes for typical image files are usually greater than 2 KB, and exceptionally large file sizes for big image files, such as background images, are usually greater than 150 KB. To optimize graphics performance for images that require lots of memory, use IXRApplication::LoadImageFromResource instead of IXRApplication::LoadImageFromFile.
When you call IXRApplication::LoadImageFromResource, XAML for Windows Embedded loads graphic images from a binary resource file, such as a .dll file or .exe file, that you registered by calling IXRApplication::AddResourceModule.
If you want to call IXRApplication::LoadImageFromResource, prepare image resources for your application by first running XRPack at the command line and setting the ImageNoCompress option, as shown in the following example. This option converts an image to an uncompressed bitmap instead of a compressed bitmap. By using uncompressed bitmaps, you can reduce the time that would be required to parse a compressed bitmap to an uncompressed bitmap at run time.
C:\WINCE800\public\COMMON\oak\bin\i386>xrpack /AppXaml=MainPage.xaml /ImageNoCompress /ResFile=thumbnailCAMDMCM8.jpg
/TargetHeader=TestAppLocalizingImagesGenerated.h /TargetRes=TestAppLocalizingImages.rc
Microsoft (R) XRPack - XamlRuntime resource packaging utility version 7.00.437
Copyright (C) Microsoft Corporation. All rights reserved.
TargetHeader = C:\WINCE800\public\COMMON\oak\bin\i386\TestAppLocalizingImagesGenerated.h
TargetRes = C:\WINCE800\public\COMMON\oak\bin\i386\TestAppLocalizingImages.rc
Targets up to date.
For more information, see XAML Resource Packager.