Issue
I want to get a picture from a MapBox MapView, but only returns a transparent image with MapBox Logo.
This is the code, thanks!:
public File getBitmapFromView(View view) {
Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(),Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(returnedBitmap);
Drawable bgDrawable =view.getBackground();
if (bgDrawable!=null)
bgDrawable.draw(canvas);
else
canvas.drawColor(Color.WHITE);
view.draw(canvas);
File file = new File(Utils.getAppFolder() + currentTrack.getDate().toString().replace(" ", "_").replace(":","_") + ".png");
try{
file.createNewFile();
}catch(IOException e){
Utils.logError("IOException: Exception in create new File: " + e.toString() );
}
FileOutputStream fileos = null;
try{
fileos = new FileOutputStream(file);
}catch(FileNotFoundException e){
Log.e("FileNotFoundException",e.toString());
}
returnedBitmap.compress(Bitmap.CompressFormat.PNG, 80, fileos);
return file;
}
Solution
Solved!,
Here is the explanation and the code to fix this issue
https://github.com/mapbox/mapbox-gl-native/issues/3677
Answered By - Emilio Baena
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.