[Video - 30 mins] Optimizing Layers within the Layer Manager using custom palette colors and optimal memory usage

NOTE: Since the time this article was written, we have come up with a “hybrid” method wherein you start the process in Photoshop with the intent to “visually collect” lots of representative images, then flatten/convert all of that into a single 256 color image that will be placed in a layer to generate one palette. You repeat the process for each major color set. Example color sets are listed below:
 
red/orange/yellow
blue/violet
green (green is commonly uncooperative, and is used a lot in photos – but this method allows you to test your greens in another set)
grayscales
browns/sepia – can maybe fold these into the yellow/orange set
 
Below is a knowledge base video showing this hybrid process. The method described in text further below is still a viable option as well, but this newer process shown in the video can possibly move things along much faster, and also allows your own eyes to judge the quality of the overall palette across multiple images.

 

Here is the helper logic to update a lot of layers at once to use the same pal file (mentioned in the video):

 

GLOBALS holder_str_var
//
GLOBALS anim_suffix
//
GLOBALS disp_prefix
//
//
//
WHEN update_layers_now == {}
 //
 // change the display object prefix, range start, range end, anim_suffix, and desired value for each call
 //
 CALL update_layers {"display" 1 3000 "palette" "mypalname.pal"} {}
 //
 END  
//
ROUTINE update_layers {disp_prefix start end anim_suffix disp_val} {}
 //
 EXPR loop_cnt {start}
 EXPR loop_end {end + 1}
 LOOP loop_cnt < {loop_end}
  //
  EXPR holder_str_var {[$format "%s_layer_id" disp_prefix]}
  EXPR @holder_str_var {loop_cnt}
  EXPR holder_str_var {[$format "%s_layer_%s" disp_prefix "format"]}
  IF @holder_str_var == 5 OR @holder_str_var == 6
   EXPR holder_str_var {[$format "%s_layer_%s" disp_prefix anim_suffix]}
   EXPR @holder_str_var {disp_val}
   //
   //
   END  
  EXPR loop_cnt {loop_cnt + 1}
  END

 

Here is the original/non-hybrid method which does not use Photoshop as shown in the video above:

  1. Create a palette .dsn file that contains a single Layer Manager
    1. You can start with the existing .dsn to get a jumpstart
  2. Create a PAL or APAL layer for each palette you want to create.
    1. We can have a maximum of 8 palettes before the Vybrid target switches from static palette loading to dynamic palette loading at runtime
    2. Static palette loading is much friendlier on bandwidth and runs faster
    3. Delete all other layers so we only 8 or fewer layers. TIP: If your main dsn has tons of layers, it might be better to start a new dsn file, and import the "flat" photoproto content once again, then dump similar colored images in each of the 8 palette layers mentioned above.
  3. Put all images that will share a palette into the same layer.  Some Examples
    1. All background images with a “silver” theme into one layer
    2. All white/blue icons into one layer
    3. All gray icons into one layer
    4. All orange/red icons into one layer
  4. Generate code for the palette .dsn
  5. Rename the .pal files that are created during code generation.  Example using the layers from step 3 above:
    1. Rename xxx_palette_L0.pal to “silver.pal”
    2. Rename xxx_palette_L1.pal to “icons.pal”
    3. Rename xxx_palette_L2.pal to “gray.pal”
    4. Etc.
  6. Open the original model.dsn file and assign the palettes to the layers:
    1. All white/blue APAL layers get the “icons.pal” for the palette
    2. All background images get “silver.pal” for the palette
    3. *all* PAL and APAL layers must have a palette assigned.  If necessary revisit step 3 to ensure all images are in one of the master palette layers.
  7. Generate code for model.dsn and verify the results.
    1. The “model_pcolors_count” variable should be less than 2048
    2. The variable is in data.c around line 650-ish: ALTIA_CONST ALTIA_INT model_pcolors_count = 10955
    3. TIP: If your main dsn has hundreds of layers, use the Control code below the video to update a range of layers based on layer ID.

    RELATED TOPIC: When using the Layer Manager to target hardware with hardware-based layers, it is sometimes suggested that you create one object per layer, which allows the hardware to clock the image content directly from flash storage, using very little RAM and CPU int he process. The flat structure is a perfect fit to assemble complex screens using the Layer Group feature of the Layer Manager pane. PhotoProto cannot created nested objects, only many objects at the same level, and it can create Image objects, Decks, and Text I/Os -- this is the perfect starting point to bring content into Altia Design before dragging those objects into individual layers using the Navigator pane in Altia Design. To see this workflow, please watch this video:

https://altia.zendesk.com/entries/47916149--Video-30-mins-Psd-Layers-to-Hardware-Based-Layers-in-30-mins-or-Less-

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.