mirror of
https://gitlab.com/2009scape/rt4-client.git
synced 2025-12-09 16:45:46 -07:00
Export transparent image for playground's HD mode
This commit is contained in:
parent
5559eaec8f
commit
c7213e4e5f
1 changed files with 18 additions and 19 deletions
|
|
@ -171,7 +171,7 @@ public class Playground extends GameShell {
|
||||||
}
|
}
|
||||||
} else if (state == 7) {
|
} else if (state == 7) {
|
||||||
if (useGl) {
|
if (useGl) {
|
||||||
GlRenderer.init(GameShell.canvas, 16);
|
GlRenderer.init(GameShell.canvas, 0);
|
||||||
if (GlRenderer.enabled) {
|
if (GlRenderer.enabled) {
|
||||||
GlRenderer.setCanvasSize(GameShell.canvasWidth, GameShell.canvasHeight);
|
GlRenderer.setCanvasSize(GameShell.canvasWidth, GameShell.canvasHeight);
|
||||||
GlRenderer.method4173();
|
GlRenderer.method4173();
|
||||||
|
|
@ -205,28 +205,27 @@ public class Playground extends GameShell {
|
||||||
public static boolean useGl = true;
|
public static boolean useGl = true;
|
||||||
|
|
||||||
private void exportGlImage(String filename) {
|
private void exportGlImage(String filename) {
|
||||||
try {
|
GL2 gl = GLContext.getCurrentGL().getGL2();
|
||||||
GL2 gl = GLContext.getCurrentGL().getGL2();
|
ByteBuffer buffer = GLBuffers.newDirectByteBuffer(GameShell.canvasWidth * GameShell.canvasHeight * 3);
|
||||||
|
|
||||||
BufferedImage image = new BufferedImage(GameShell.canvasWidth, GameShell.canvasHeight, BufferedImage.TYPE_INT_RGB);
|
gl.glReadBuffer(GL2.GL_BACK);
|
||||||
Graphics graphics = image.getGraphics();
|
gl.glReadPixels(0, 0, GameShell.canvasWidth, GameShell.canvasHeight, GL2.GL_BGR, GL2.GL_UNSIGNED_BYTE, buffer);
|
||||||
|
|
||||||
ByteBuffer buffer = GLBuffers.newDirectByteBuffer(GameShell.canvasWidth * GameShell.canvasHeight * 4);
|
int[] pixels = new int[GameShell.canvasWidth * GameShell.canvasHeight];
|
||||||
|
for (int y = GameShell.canvasHeight; y > 0; ++y) {
|
||||||
gl.glReadBuffer(GL2.GL_BACK);
|
for (int x = 0; x < GameShell.canvasWidth; ++x) {
|
||||||
gl.glReadPixels(0, 0, GameShell.canvasWidth, GameShell.canvasHeight, GL2.GL_RGBA, GL2.GL_UNSIGNED_BYTE, buffer);
|
int r = buffer.get() & 0xFF;
|
||||||
|
int g = buffer.get() & 0xFF;
|
||||||
for (int h = 0; h < GameShell.canvasHeight; h++) {
|
int b = buffer.get() & 0xFF;
|
||||||
for (int w = 0; w < GameShell.canvasWidth; w++) {
|
int a = 255;
|
||||||
graphics.setColor(new Color((buffer.get() & 0xff), (buffer.get() & 0xff), (buffer.get() & 0xff)));
|
if (r == 0x33 && g == 0x33 && b == 0x33) {
|
||||||
buffer.get();
|
a = 0x7F;
|
||||||
graphics.drawRect(w, GameShell.canvasHeight - h, 1, 1);
|
|
||||||
}
|
}
|
||||||
|
pixels[x + y * GameShell.canvasWidth] = r | (g << 8) | (b << 16) | (a << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageIO.write(image, "PNG", new File(filename + ".png"));
|
|
||||||
} catch (IOException ex) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exportImage(pixels, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exportImage(int[] pixels, String filename) {
|
private void exportImage(int[] pixels, String filename) {
|
||||||
|
|
@ -351,7 +350,7 @@ public class Playground extends GameShell {
|
||||||
if (!GlRenderer.enabled) {
|
if (!GlRenderer.enabled) {
|
||||||
SoftwareRaster.clear(0x7F666666);
|
SoftwareRaster.clear(0x7F666666);
|
||||||
} else {
|
} else {
|
||||||
GlRenderer.clearColorAndDepthBuffers(0x7F333333);
|
GlRenderer.clearColorAndDepthBuffers(0x333333);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (npc != null) {
|
if (npc != null) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue