Android / AWT interfaces improvements, closes #7

This commit is contained in:
Emux 2016-06-17 13:08:30 +03:00
parent 35d8d2d57e
commit b8d382a9f3
4 changed files with 25 additions and 0 deletions

View File

@ -1,5 +1,6 @@
/*
* Copyright 2010, 2011, 2012 mapsforge.org
* Copyright 2016 devemux86
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@ -41,6 +42,10 @@ public final class AndroidGraphics extends CanvasAdapter {
return ((AndroidPaint) paint).mPaint;
}
public static android.graphics.Bitmap getBitmap(Bitmap bitmap) {
return ((AndroidBitmap) bitmap).mBitmap;
}
private AndroidGraphics() {
// do nothing
}

View File

@ -1,5 +1,6 @@
/*
* Copyright 2010, 2011, 2012 mapsforge.org
* Copyright 2016 devemux86
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@ -41,6 +42,10 @@ public final class AndroidGraphics extends CanvasAdapter {
return ((AndroidPaint) paint).mPaint;
}
public static android.graphics.Bitmap getBitmap(Bitmap bitmap) {
return ((AndroidBitmap) bitmap).mBitmap;
}
private AndroidGraphics() {
// do nothing
}

View File

@ -1,5 +1,6 @@
/*
* Copyright 2013 Hannes Janetzek
* Copyright 2016 devemux86
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@ -58,6 +59,15 @@ public class AwtBitmap implements Bitmap {
this.bitmap.coerceData(true);
}
public AwtBitmap(BufferedImage bitmap) {
this.bitmap = bitmap;
this.width = this.bitmap.getWidth();
this.height = this.bitmap.getHeight();
if (!this.bitmap.isAlphaPremultiplied()
&& this.bitmap.getType() == BufferedImage.TYPE_INT_ARGB)
this.bitmap.coerceData(true);
}
@Override
public int getWidth() {
return width;

View File

@ -1,5 +1,6 @@
/*
* Copyright 2013 Hannes Janetzek
* Copyright 2016 devemux86
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@ -35,6 +36,10 @@ public class AwtGraphics extends CanvasAdapter {
CanvasAdapter.init(new AwtGraphics());
}
public static BufferedImage getBitmap(Bitmap bitmap) {
return ((AwtBitmap) bitmap).bitmap;
}
private AwtGraphics() {
// do nothing
}