Skip to content

Theme resources problem with displayModel.setThemeCallback? #1619

Closed

Description

@wharnisch

To replace the displayModel.setFilter method, which is no longer available in the latest version of the library, I now use the displayModel.setThemeCallback method to get a grayed-out version of the map, for example. I noticed that not all parts of the map can be recolored with this method. This can be best seen when using the DEFAULT theme.

Problem can be reproduced by:
map.getModel().displayModel.setThemeCallback( (RenderInstruction origin, int color) -> 0x80FF0000);

This should result in my understanding in a fully red area. But this is not the case. I attached to screenshots where the map with and without the themeCallback set can be seen.

mapWithoutThemeCallback
mapWithThemeCallback

Activity

  1. devemux86 commented on Jan 12, 2025

    @devemux86
    Collaborator

    Colors can be easily modified by apps in the callback, not the images.
    Or use a theme without patterns in the areas, but fill them with color.

    The best is to have different themes, like the Motorider light / dark theme by @MotoUKRider.

  2. Sublimis commented on Jan 12, 2025

    @Sublimis
    Contributor

    @wharnisch We also came across this a while ago, so just to clarify, what is seen as non-red areas are actually SVG or PNG images coming from the assets folder: https://github.com/mapsforge/mapsforge/blob/master/mapsforge-themes/src/main/resources/assets/patterns/farmland.svg. Theme callback cannot color these items for some reason.

  3. devemux86 commented on Jan 12, 2025

    @devemux86
    Collaborator

    We could extend the callback for the resources too, if this is possible.

    But the processing / recoloring is work for the apps, not the library.
    This is the purpose of the callback, to provide total freedom for the apps.

  4. wharnisch commented on Jan 13, 2025

    @wharnisch
    Author

    I think ThemeCallback API cannot fully replace the functionality of deprectated and removed Filter API. At least my task of graying out the map, for which I previously used the Filter API in my Android apps, can no longer be implemented with this. It would be nice to have something like the Android's ColorFilter API available.

  5. added this to the 0.24.0 milestone on Jan 13, 2025
  6. changed the title [-]Problem with displayModel.setThemeCallback?[/-] [+]Theme resources problem with displayModel.setThemeCallback?[/+] on Jan 13, 2025
  7. devemux86 commented on Jan 13, 2025

    @devemux86
    Collaborator

    Fixed by #1622.

    Color filter theme resources with the ThemeCallback.getBitmap.
    An example can be found in the ColorFilterMapViewer sample.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions