fix AwtBitmap

- set dimension for bitmaps read from InputStream
- convert to premultiplied alpha
This commit is contained in:
Hannes Janetzek 2013-06-24 15:44:15 +02:00
parent a2c30e5321
commit 75ef8f83e1

View File

@ -24,6 +24,8 @@ public class AwtBitmap implements Bitmap {
bitmap = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
this.width = width;
this.height = height;
if (!this.bitmap.isAlphaPremultiplied())
this.bitmap.coerceData(true);
}
AwtBitmap(InputStream inputStream) throws IOException {
@ -33,6 +35,7 @@ public class AwtBitmap implements Bitmap {
if (!this.bitmap.isAlphaPremultiplied())
this.bitmap.coerceData(true);
}
@Override
public int getWidth() {
return width;
@ -45,13 +48,11 @@ public class AwtBitmap implements Bitmap {
@Override
public int[] getPixels() {
// TODO Auto-generated method stub
return null;
}
@Override
public void eraseColor(int transparent) {
// TODO Auto-generated method stub
}
private static IntBuffer tmpBuffer = BufferUtils.newIntBuffer(512 * 256);
@ -66,14 +67,13 @@ public class AwtBitmap implements Bitmap {
pixels = tmpPixel;
buffer = tmpBuffer;
buffer.clear();
Log.d("AwtBitmap", "default texture");
//Log.d("AwtBitmap", "default texture");
} else {
pixels = new int[width * height];
buffer = BufferUtils.newIntBuffer(width * height);
Log.d("AwtBitmap", "create texture buffer " + width + "x" + height);
//Log.d("AwtBitmap", "create texture buffer " + width + "x" + height);
}
bitmap.getRGB(0, 0, width, height, pixels, 0, width);
buffer.put(pixels);
@ -88,6 +88,5 @@ public class AwtBitmap implements Bitmap {
@Override
public void recycle() {
// TODO Auto-generated method stub
}
}