use text texture size for buffered gdx/awt image loading
This commit is contained in:
parent
52813ea29f
commit
af3ee3a742
@ -25,6 +25,7 @@ import java.nio.IntBuffer;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.renderer.elements.TextureLayer;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
@ -76,8 +77,10 @@ public class AwtBitmap implements Bitmap {
|
||||
public void eraseColor(int transparent) {
|
||||
}
|
||||
|
||||
private final static IntBuffer tmpBuffer = BufferUtils.newIntBuffer(512 * 256);
|
||||
private final static int[] tmpPixel = new int[512 * 256];
|
||||
private final static IntBuffer tmpBuffer = BufferUtils.newIntBuffer(TextureLayer.TEXTURE_HEIGHT
|
||||
* TextureLayer.TEXTURE_WIDTH);
|
||||
private final static int[] tmpPixel = new int[TextureLayer.TEXTURE_HEIGHT
|
||||
* TextureLayer.TEXTURE_WIDTH];
|
||||
|
||||
private final static boolean WRITE_TEX = false;
|
||||
private int dbgCnt;
|
||||
@ -87,7 +90,7 @@ public class AwtBitmap implements Bitmap {
|
||||
int[] pixels;
|
||||
IntBuffer buffer;
|
||||
|
||||
if (width * height < 512 * 256) {
|
||||
if (width * height < TextureLayer.TEXTURE_HEIGHT * TextureLayer.TEXTURE_WIDTH) {
|
||||
pixels = tmpPixel;
|
||||
buffer = tmpBuffer;
|
||||
buffer.clear();
|
||||
@ -112,6 +115,8 @@ public class AwtBitmap implements Bitmap {
|
||||
|
||||
for (int i = 0, n = width * height; i < n; i++) {
|
||||
int c = pixels[i];
|
||||
if (c == 0)
|
||||
continue;
|
||||
|
||||
float alpha = (c >>> 24) / 255f;
|
||||
int r = (int) ((c & 0x000000ff) * alpha);
|
||||
|
@ -74,17 +74,17 @@ public class AwtCanvas implements Canvas {
|
||||
canvas.drawString(text, x + 2, y);
|
||||
} else {
|
||||
setColorAndStroke(awtPaint);
|
||||
TextLayout textLayout = new TextLayout(text,
|
||||
awtPaint.font,
|
||||
canvas.getFontRenderContext());
|
||||
AffineTransform affineTransform = new AffineTransform();
|
||||
affineTransform.translate(x + 2, y);
|
||||
canvas.draw(textLayout.getOutline(affineTransform));
|
||||
TextLayout tl = new TextLayout(text, awtPaint.font, canvas.getFontRenderContext());
|
||||
AffineTransform tx = new AffineTransform();
|
||||
tx.translate(x + 2, y);
|
||||
canvas.draw(tl.getOutline(tx));
|
||||
canvas.drawString(text, x + 2, y);
|
||||
}
|
||||
}
|
||||
|
||||
private void setColorAndStroke(AwtPaint awtPaint) {
|
||||
canvas.setColor(awtPaint.color);
|
||||
|
||||
if (awtPaint.stroke != null) {
|
||||
canvas.setStroke(awtPaint.stroke);
|
||||
}
|
||||
|
@ -37,8 +37,8 @@ public abstract class TextureLayer extends RenderElement {
|
||||
final static int VERTICES_PER_SPRITE = 4;
|
||||
final static int SHORTS_PER_VERTICE = 6;
|
||||
|
||||
final static int TEXTURE_HEIGHT = 128;
|
||||
final static int TEXTURE_WIDTH = 512;
|
||||
public final static int TEXTURE_HEIGHT = 128;
|
||||
public final static int TEXTURE_WIDTH = 512;
|
||||
final static int POOL_FILL = 10;
|
||||
|
||||
/** pool shared by TextLayers */
|
||||
|
Loading…
x
Reference in New Issue
Block a user