diff --git a/vtm-gdx-desktop/src/org/oscim/awt/AwtBitmap.java b/vtm-gdx-desktop/src/org/oscim/awt/AwtBitmap.java index 3f7e405a..e07d3623 100644 --- a/vtm-gdx-desktop/src/org/oscim/awt/AwtBitmap.java +++ b/vtm-gdx-desktop/src/org/oscim/awt/AwtBitmap.java @@ -14,7 +14,6 @@ import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.utils.BufferUtils; public class AwtBitmap implements Bitmap { - BufferedImage bitmap; int width; int height; @@ -28,6 +27,7 @@ public class AwtBitmap implements Bitmap { } AwtBitmap(InputStream inputStream) throws IOException { + this.bitmap = ImageIO.read(inputStream); this.width = this.bitmap.getWidth(); this.height = this.bitmap.getHeight(); @@ -62,20 +62,24 @@ public class AwtBitmap implements Bitmap { int[] pixels; IntBuffer buffer; - if (width == 512 && height == 256) { + if (width * height < 512 * 256) { pixels = tmpPixel; buffer = tmpBuffer; buffer.clear(); - //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); } bitmap.getRGB(0, 0, width, height, pixels, 0, width); - buffer.put(pixels); + for (int i = 0, n = width * height; i < n; i++){ + int c = pixels[i]; + // flip blue with red - silly Java + pixels[i] = (c & 0xff00ff00) | (c & 0x00ff0000) >>> 16 | (c & 0x000000ff) << 16; + } + + buffer.put(pixels, 0, width * height); buffer.flip(); Gdx.gl20.glTexImage2D(GL20.GL_TEXTURE_2D, 0, GL20.GL_RGBA, width, diff --git a/vtm-gdx-desktop/src/org/oscim/awt/AwtPaint.java b/vtm-gdx-desktop/src/org/oscim/awt/AwtPaint.java index 868e0611..58b24565 100644 --- a/vtm-gdx-desktop/src/org/oscim/awt/AwtPaint.java +++ b/vtm-gdx-desktop/src/org/oscim/awt/AwtPaint.java @@ -28,8 +28,6 @@ import java.util.Map; import org.oscim.backend.canvas.Bitmap; import org.oscim.backend.canvas.Paint; -import com.badlogic.gdx.Gdx; - public class AwtPaint implements Paint { private static int getCap(Cap cap) {