Keep original Image Names

Currently the exported image names get changed to seemingly random names such as ui_img_260456555_data. Can we have a setting to keep the original name? I need to load images at runtime and can’t reliably pick the correct ones.

It shouldn’t happen. The name of the image variables should be created from the PNG’s filename. Are there non-ASCII characters in the image file names?

No unusual charaacters. Here are a few examples.

// IMAGE DATA: assets\icon_conditions_thunderstorm-24x24.png
const LV_ATTRIBUTE_MEM_ALIGN uint8_t ui_img_260456555_data[] = {

// IMAGE DATA: assets\icon_humidity-24x24.png
const LV_ATTRIBUTE_MEM_ALIGN uint8_t ui_img_282688504_data[] = {

// IMAGE DATA: assets\icon_pressure-24x24.png
const LV_ATTRIBUTE_MEM_ALIGN uint8_t ui_img_865334226_data[] = {

it seems like having a dash (“-”) in the filename causes this. Not sure why that would be considered a restricted character. Maybe it’s a bug?

The file name and variable name will be the same, and - can’t be used in variable names. In this case SLS generates a hash for the file name.

So you should replace - with _.

Got it. Thank you.

It might be nice if SquareLine studio could escape or convert these image names to C identifiers automatically, and only fallback to a synthetic ID if the C identifier collided or otherwise wouldn’t work.

Hi, thanks for the suggestion. We’ll add this functionality in the next SquareLine Studio release.

1 Like

Just noting that the hyphenated image numbering scheme changed between SquareLine 1.6.1 and 1.6.2. Looking forward to kinder handling of these. Thanks as always SLS team!

1 Like

Hi Richard, thanks for following up, and sorry this took longer than we said. The readable naming didn’t make it into 1.6.2, but it’s done and will be in the next release:

  • Image file names are converted to C identifiers automatically: any character other than a letter, digit or underscore becomes _. So icon_humidity-24x24.png becomes ui_img_icon_humidity_24x24_png.
  • The same applies to image sequences: loader-01.png, loader-02.png… give ui_imgset_loader_.
  • A numeric ID is only used if two files would end up with the same name (e.g. icon-a.png and icon_a.png). Even then, the file that already had a valid name keeps it, and the number is now computed from the file path, so it won’t change between versions.

One heads-up: after updating, the hyphenated images will get these new names instead of ui_img_<number>, so if you reference them in your own code, you’ll need to update those references once.

1 Like