How do I draw multiple images in settings?

The goal is to draw multiple images through settings. Does anyone know how to do so?

I currently have the following code after function onLayout(dc). Is the code correctly placed and written?

When I update in the simulator, the bitmap does not change...

function checkLoadedImage() {

        var system = System.getDeviceSettings().BackgroundImageTitle;

        if (system==false) {

                bitmap = WatchUi.loadResource(Rez.Drawables.imageI);

        } else {

          if (Application.getApp().getProperty("BackgroundImage") == 0) {

            bitmap = Ui.loadResource(Rez.Drawables.imageI);        

        } else if (Application.getApp().getProperty("BackgroundImage") == 1) {

            bitmap = Ui.loadResource(Rez.Drawables.imageII);

        } else if (Application.getApp().getProperty("BackgroundImage")==2) {

                bitmap = Ui.loadResource(Rez.Drawables.imageIII);

                                                        

  • I went ahead and coded it into the extends Application.AppBase and placed it after function initialize() and before function onStart(state). But its given me the below error. I went ahead and replaced the symbol into the Application.getApp().getProperty, strings, settings, and the property.

    I am still receiving the same message after I tried editing the symbol elsewhere...  Hopefully I am going the right direction?

    Error: Symbol Not Found Error

    Details: Could not find symbol 'BackgroundImageTitle'

    Stack: 

      - onSettingsChanged() tApp.mc:12 0x100000b6.

  • Sounds like BackgroundImageTitle is defined in your view class.  Move it outside the class, making it a global is the fastest solution.

  • view class does not have BackgroundImageTitle. it is only in the app class. it seems the nomenclature "BackgroundImageTitle" on var system = System.getDeviceSettings().BackgroundImageTitle; may be the initial issue.

    I ran the sim with only var system = System.getDeviceSettings() and i received another error for the var bmWidth=bitmap.getWidth();

    Error: Unexpected Type Error

    Details: Failed invoking <symbol>

    Stack: 

      - onSettingsChanged() at App.mc:14

  • function onSettingsChanged() {
        var system = System.getDeviceSettings().BackgroundImageTitle;
        var bmWidth=bitmap.getWidth();
        width=dc.getWidth();
        height=dc.getHeight();
        if (system==false) {
            bitmap = WatchUi.loadResource(Rez.Drawables.imageI);
        } else {
            if (Application.getApp().getProperty("BackgroundImage") == 0) {
                bitmap = WatchUi.loadResource(Rez.Drawables.imageII);
                dc.drawBitmap(width/2-bmWidth/2,0, bitmap);
            
            } else if (Application.getApp().getProperty("BackgroundImage") == 1) {
                bitmap = WatchUi.loadResource(Rez.Drawables.imageIII);
                dc.drawBitmap(width/2-bmWidth/2,0, bitmap);
            
            } else if (Application.getApp().getProperty("BackgroundImage")==2) {
                bitmap = WatchUi.loadResource(Rez.Drawables.HomageVermont100Ultramarathon);
                dc.drawBitmap(width/2-bmWidth/2,0, bitmap);
            }
        }
    }
    

    it seems the nomenclature "BackgroundImageTitle" on var system = System.getDeviceSettings().BackgroundImageTitle; may be the initial issue

    Yes. The object returned by the expression System.getDeviceSettings() is a System.DeviceSettings. That type does not have a BackgroundImageTitle field, so you'll get a symbol not found error at runtime.

    Once you eliminate that error, you'll run into the next problem. As far as I can tell from your code, you have either a member or global variable named bitmap. Immediately after you make the getDeviceSettings call, you try to call bitmap.getWidth(). If it is failing here, it is most likely because bitmap has not been initialized yet. In that case you'd expect to get an unexpected type error because you are calling a function on the null object.

  • What would be the appropriate field for the System.getDeviceSettings() for images? I tried replacing BackgroundImageTitle with image_theme, then I tried draw(dc). Id like to figure this out so I can move to the next potential problem as you mentioned...

  • What would be the appropriate field for the System.getDeviceSettings() for images? I tried

    I have no idea what you are trying to do, so I can't help with that.

    The object returned by that expression is a DeviceSettings. You can look at the documentation for the list of fields that it has here:

    https://developer.garmin.com/connect-iq/api-docs/Toybox/System/DeviceSettings.html

  • Given this...

    var system = System.getDeviceSettings().BackgroundImageTitle;
    

    and this...

    if (Application.getApp().getProperty("BackgroundImage") == 0) {

    it seems that you might be trying to get the value of a setting/property called "BackgroundImageTitle"?

  • My ultimate goal is to allow a user to update their background with their image of choice through a coded bitmap. Similar to when they choose foreground or background color.