Bitmap: get png encoded data implementation

This commit is contained in:
Longri
2016-07-17 21:21:58 +02:00
committed by Emux
parent fab7020d3d
commit 44b40608f6
5 changed files with 37 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ import android.graphics.BitmapFactory;
import android.opengl.GLES20;
import android.opengl.GLUtils;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import static android.graphics.Bitmap.Config.ARGB_8888;
@@ -43,6 +44,13 @@ 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
*/