Skip to content

Instantly share code, notes, and snippets.

@patrickhammond
Created June 23, 2016 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickhammond/a206c80f5c2a62101594c51931163939 to your computer and use it in GitHub Desktop.
Save patrickhammond/a206c80f5c2a62101594c51931163939 to your computer and use it in GitHub Desktop.
Tinting a map marker.
Bitmap markerBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.mapmarker);
Bitmap resultBitmap = Bitmap.createBitmap(markerBitmap, 0, 0, markerBitmap.getWidth() - 1, markerBitmap.getHeight() - 1);
ColorFilter filter = new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
Paint markerPaint = new Paint();
markerPaint.setColorFilter(filter);
Canvas canvas = new Canvas(resultBitmap);
canvas.drawBitmap(resultBitmap, 0, 0, markerPaint);
markerOptions.icon(BitmapDescriptorFactory.fromBitmap(resultBitmap));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment