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:
- Create a palette .dsn file that contains a single Layer Manager
- You can start with the existing .dsn to get a jumpstart
- Create a PAL or APAL layer for each palette you want to create.
- We can have a maximum of 8 palettes before the Vybrid target switches from static palette loading to dynamic palette loading at runtime
- Static palette loading is much friendlier on bandwidth and runs faster
- 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.
- Put all images that will share a palette into the same layer. Some Examples
- All background images with a “silver” theme into one layer
- All white/blue icons into one layer
- All gray icons into one layer
- All orange/red icons into one layer
- Generate code for the palette .dsn
- Rename the .pal files that are created during code generation. Example using the layers from step 3 above:
- Rename xxx_palette_L0.pal to “silver.pal”
- Rename xxx_palette_L1.pal to “icons.pal”
- Rename xxx_palette_L2.pal to “gray.pal”
- Etc.
- Open the original model.dsn file and assign the palettes to the layers:
- All white/blue APAL layers get the “icons.pal” for the palette
- All background images get “silver.pal” for the palette
- *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.
- Generate code for model.dsn and verify the results.
- The “model_pcolors_count” variable should be less than 2048
- The variable is in data.c around line 650-ish: ALTIA_CONST ALTIA_INT model_pcolors_count = 10955
- 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-