cleanup pixmap

This commit is contained in:
Anthony Calosa
2023-02-20 14:09:35 +08:00
parent 32c01c709d
commit 0ca9039c29
2 changed files with 12 additions and 7 deletions

View File

@@ -32,7 +32,7 @@ public abstract class DrawOnPixmap {
BitmapFont font = bigText ? Controls.getBitmapFont("big") : Controls.getBitmapFont("default");
FrameBuffer frameBuffer = new FrameBuffer(Pixmap.Format.RGB888, drawingMap.getWidth(), drawingMap.getHeight(), false);
SpriteBatch batch=new SpriteBatch();
SpriteBatch batch = new SpriteBatch();
frameBuffer.begin();
@@ -46,16 +46,17 @@ public abstract class DrawOnPixmap {
batch.begin();
//Rendering ends here. Create a new Pixmap to Texture with mipmaps, otherwise will render as full black.
Texture texture = new Texture(drawingMap);
batch.draw(texture,0,0);
batch.draw(texture, 0, 0);
font.setColor(color);
font.draw(batch,itemText,x,y,width, Align.center,true);
font.draw(batch, itemText, x, y, width, Align.center, true);
batch.end();
drawingMap.drawPixmap(Pixmap.createFromFrameBuffer(0, 0, drawingMap.getWidth(), drawingMap.getHeight()),0,0);
Pixmap pixmap = Pixmap.createFromFrameBuffer(0, 0, drawingMap.getWidth(), drawingMap.getHeight());
drawingMap.drawPixmap(pixmap, 0, 0);
frameBuffer.end();
texture.dispose();
batch.dispose();
pixmap.dispose();
if (bigText) //don't know why this is needed to circumvent bug getting default size for the same pixelfont
Controls.getBitmapFont("default");
}
}

View File

@@ -484,10 +484,12 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
g.end();
g.endClip();
//Rendering ends here. Create a new Pixmap to Texture with mipmaps, otherwise will render as full black.
Texture result = new Texture(Pixmap.createFromFrameBuffer(0, 0, preview_w, preview_h), Forge.isTextureFilteringEnabled());
Pixmap pixmap = Pixmap.createFromFrameBuffer(0, 0, preview_w, preview_h);
Texture result = new Texture(pixmap, Forge.isTextureFilteringEnabled());
frameBuffer.end();
g.dispose();
frameBuffer.dispose();
pixmap.dispose();
return result;
}
@@ -519,7 +521,9 @@ public class RewardActor extends Actor implements Disposable, ImageFetcher.Callb
}
getGraphics().end();
getGraphics().endClip();
generatedTooltip = new Texture(Pixmap.createFromFrameBuffer(0, 0, preview_w, preview_h), Forge.isTextureFilteringEnabled());
Pixmap pixmap = Pixmap.createFromFrameBuffer(0, 0, preview_w, preview_h);
generatedTooltip = new Texture(pixmap, Forge.isTextureFilteringEnabled());
pixmap.dispose();
} catch (Exception e) {
//e.printStackTrace();
} finally {