Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

NativeMapView.addImage without copying bitmap into Java - #11111

Merged
tobrun merged 2 commits into
release-bobafrom
tvn-add-image
Feb 12, 2018
Merged

tobrun merged 2 commits into
release-bobafrom
tvn-add-image

Conversation

@tobrun

@tobrun tobrun commented Feb 2, 2018

Copy link
Copy Markdown
Member

Follow up from external PR in #11000. Capturing from @ivovandongen that the config validation part should be re-added:

    // Check/correct config
    if (image.getConfig() != Bitmap.Config.ARGB_8888) {
      image = image.copy(Bitmap.Config.ARGB_8888, false);
    }

cc @jaegs

@tobrun tobrun added the Android Mapbox Maps SDK for Android label Feb 2, 2018
@tobrun tobrun added this to the android-v6.0.0 milestone Feb 2, 2018
@tobrun tobrun self-assigned this Feb 2, 2018
@tobrun
tobrun requested a review from ivovandongen February 2, 2018 10:19
@jaegs

jaegs commented Feb 2, 2018 •

Copy link
Copy Markdown

Maybe the validation part should go here:

if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
// TODO: convert
throw std::runtime_error("bitmap decoding: bitmap format invalid");
}

@tobrun

tobrun commented Feb 9, 2018

Copy link
Copy Markdown
Member Author

@jaegs you are right, will add the conversion on the c++ side.

@ivovandongen I tested image conversion with:

Bitmap bitmap = Bitmap.createBitmap(createColors(), WIDTH, HEIGHT, Bitmap.Config.RGB_565);
mapboxMap.addImage("image", bitmap);

GeoJsonSource geoJsonSource = new GeoJsonSource("source", Feature.fromGeometry(Point.fromCoordinates(new double[] {0, 0})));
mapboxMap.addSource(geoJsonSource);

SymbolLayer symbolLayer = new SymbolLayer("layer", "source");
symbolLayer.withProperties(iconImage("image"));
mapboxMap.addLayer(symbolLayer);

And I was able to debug that the conversion is happening as expected:

screen shot 2018-02-09 at 10 54 44

This resulted in:

screen shot 2018-02-09 at 10 56 11

Comment thread platform/android/src/bitmap.cpp Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be static to cache the method lookup

@tobrun

tobrun commented Feb 12, 2018

Copy link
Copy Markdown
Member Author

Could you re-review @ivovandongen? static keyword was added.

@tobrun
tobrun merged commit ff747a8 into release-boba Feb 12, 2018
@tobrun
tobrun deleted the tvn-add-image branch February 12, 2018 14:57
@tobrun tobrun mentioned this pull request Feb 13, 2018
10 of 23 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Android Mapbox Maps SDK for Android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants