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

@@ -50,12 +50,13 @@ public abstract class DrawOnPixmap {
font.setColor(color); 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(); 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(); frameBuffer.end();
texture.dispose(); texture.dispose();
batch.dispose(); batch.dispose();
pixmap.dispose();
if (bigText) //don't know why this is needed to circumvent bug getting default size for the same pixelfont if (bigText) //don't know why this is needed to circumvent bug getting default size for the same pixelfont
Controls.getBitmapFont("default"); Controls.getBitmapFont("default");
} }
} }

View File

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