Bitmap.getPngEncodedData improvements, PR #71
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016 Longri
|
||||
* Copyright 2016 devemux86
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
@@ -21,6 +23,8 @@ import android.graphics.BitmapFactory;
|
||||
import android.opengl.GLES20;
|
||||
import android.opengl.GLUtils;
|
||||
|
||||
import org.oscim.utils.IOUtils;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
@@ -44,13 +48,6 @@ public class AndroidBitmap implements org.oscim.backend.canvas.Bitmap {
|
||||
return mBitmap != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getPngEncodedData(){
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
this.mBitmap.compress(Bitmap.CompressFormat.PNG, 0, outputStream);
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param format ignored always ARGB8888
|
||||
*/
|
||||
@@ -108,4 +105,16 @@ public class AndroidBitmap implements org.oscim.backend.canvas.Bitmap {
|
||||
|
||||
mBitmap.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getPngEncodedData() {
|
||||
ByteArrayOutputStream outputStream = null;
|
||||
try {
|
||||
outputStream = new ByteArrayOutputStream();
|
||||
mBitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream);
|
||||
return outputStream.toByteArray();
|
||||
} finally {
|
||||
IOUtils.closeQuietly(outputStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user