List of usage examples for com.badlogic.gdx.graphics Pixmap dispose
public void dispose()
From source file:at.tugraz.ist.catroid.content.Costume.java
License:Open Source License
protected void checkImageChanged() { imageLock.acquireUninterruptibly();/*from w w w. j a v a 2 s .co m*/ if (imageChanged) { this.disposeTextures(); currentAlphaPixmap = null; if (costumeData == null) { xYWidthHeightLock.acquireUninterruptibly(); this.x += this.width / 2f; this.y += this.height / 2f; this.width = 0f; this.height = 0f; xYWidthHeightLock.release(); this.region = new TextureRegion(); imageChanged = false; imageLock.release(); return; } Pixmap pixmap; if (internalPath) { pixmap = new Pixmap(Gdx.files.internal(costumeData.getAbsolutePath())); } else { pixmap = new Pixmap(Gdx.files.absolute(costumeData.getAbsolutePath())); } xYWidthHeightLock.acquireUninterruptibly(); this.x += this.width / 2f; this.y += this.height / 2f; this.width = pixmap.getWidth(); this.height = pixmap.getHeight(); this.x -= this.width / 2f; this.y -= this.height / 2f; this.originX = this.width / 2f; this.originY = this.height / 2f; xYWidthHeightLock.release(); currentAlphaPixmap = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), Format.Alpha); currentAlphaPixmap.drawPixmap(pixmap, 0, 0, 0, 0, pixmap.getWidth(), pixmap.getHeight()); brightnessLock.acquireUninterruptibly(); if (brightnessValue != 1f) { pixmap = this.adjustBrightness(pixmap); } brightnessLock.release(); Texture texture = new Texture(pixmap); pixmap.dispose(); this.region = new TextureRegion(texture); imageChanged = false; } imageLock.release(); }
From source file:at.tugraz.ist.catroid.content.Costume.java
License:Open Source License
protected Pixmap adjustBrightness(Pixmap currentPixmap) { Pixmap newPixmap = new Pixmap(currentPixmap.getWidth(), currentPixmap.getHeight(), currentPixmap.getFormat());/* w w w . java 2 s. co m*/ for (int y = 0; y < currentPixmap.getHeight(); y++) { for (int x = 0; x < currentPixmap.getWidth(); x++) { int pixel = currentPixmap.getPixel(x, y); int r = (int) (((pixel >> 24) & 0xff) + (255 * (brightnessValue - 1))); int g = (int) (((pixel >> 16) & 0xff) + (255 * (brightnessValue - 1))); int b = (int) (((pixel >> 8) & 0xff) + (255 * (brightnessValue - 1))); int a = pixel & 0xff; if (r > 255) { r = 255; } else if (r < 0) { r = 0; } if (g > 255) { g = 255; } else if (g < 0) { g = 0; } if (b > 255) { b = 255; } else if (b < 0) { b = 0; } newPixmap.setColor(r / 255f, g / 255f, b / 255f, a / 255f); newPixmap.drawPixel(x, y); } } currentPixmap.dispose(); return newPixmap; }
From source file:at.tugraz.ist.catroid.plugin.Drone.other.DroneVideoCostume.java
License:Open Source License
public void initializeTexture() { Pixmap pixmap = new Pixmap(320, 240, Format.RGB888); pixmap.setColor(Color.BLUE);// w ww .ja va 2s. co m pixmap.fill(); Texture texture = new Texture(pixmap, false); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); this.region = new TextureRegion(texture); this.width = this.region.getRegionWidth(); this.height = this.region.getRegionHeight(); this.x -= (this.width / 2f); this.y -= (this.height / 2f); this.originX = (this.width / 2f); this.originY = (this.height / 2f); pixmap.dispose(); firstStart = false; }
From source file:awakening.view.menu.Audio.java
License:Apache License
@Override public void render(float delta) { Gdx.gl.glClearColor(0, 0, 0, 1);/*from w w w . j a v a 2s. c o m*/ Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); Gdx.graphics.setDisplayMode(game.getSize().width, game.getSize().height, game.isFullscreen()); ///Settings game.setMusicVolume(sliderMusic.getValue() / 10); game.setSoundVolume(sliderEffects.getValue() / 10); effect.setVolume(0, game.getSoundVolume()); sound.setVolume(game.getMusicVolume()); ///Cursor Pixmap pm = new Pixmap(Gdx.files.internal("img/cursor.png")); Gdx.input.setCursorImage(pm, 0, 0); pm.dispose(); ///Draw Background batch.setProjectionMatrix(camera.combined); batch.begin(); batch.draw(background, 0, 0, Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getHeight()); batch.end(); ///Draw Stage stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); stage.draw(); }
From source file:awakening.view.menu.Controls.java
License:Apache License
@Override public void render(float delta) { Gdx.gl.glClearColor(0, 0, 0, 1);/*w w w. ja v a 2 s . c o m*/ Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); Gdx.graphics.setDisplayMode(game.getSize().width, game.getSize().height, game.isFullscreen()); if (btnUp.isChecked()) { btnUp.setColor(Color.RED); btnUp.setTouchable(Touchable.disabled); btnDown.setTouchable(Touchable.disabled); btnLeft.setTouchable(Touchable.disabled); btnRight.setTouchable(Touchable.disabled); btnZoomIn.setTouchable(Touchable.disabled); btnZoomOut.setTouchable(Touchable.disabled); btnBack.setTouchable(Touchable.disabled); setControls(btnUp); } else if (btnDown.isChecked()) { btnDown.setColor(Color.RED); btnUp.setTouchable(Touchable.disabled); btnDown.setTouchable(Touchable.disabled); btnLeft.setTouchable(Touchable.disabled); btnRight.setTouchable(Touchable.disabled); btnZoomIn.setTouchable(Touchable.disabled); btnZoomOut.setTouchable(Touchable.disabled); btnBack.setTouchable(Touchable.disabled); setControls(btnDown); } else if (btnLeft.isChecked()) { btnLeft.setColor(Color.RED); btnUp.setTouchable(Touchable.disabled); btnDown.setTouchable(Touchable.disabled); btnLeft.setTouchable(Touchable.disabled); btnRight.setTouchable(Touchable.disabled); btnZoomIn.setTouchable(Touchable.disabled); btnZoomOut.setTouchable(Touchable.disabled); btnBack.setTouchable(Touchable.disabled); setControls(btnLeft); } else if (btnRight.isChecked()) { btnRight.setColor(Color.RED); btnUp.setTouchable(Touchable.disabled); btnDown.setTouchable(Touchable.disabled); btnLeft.setTouchable(Touchable.disabled); btnRight.setTouchable(Touchable.disabled); btnZoomIn.setTouchable(Touchable.disabled); btnZoomOut.setTouchable(Touchable.disabled); btnBack.setTouchable(Touchable.disabled); setControls(btnRight); } else if (btnZoomIn.isChecked()) { btnZoomIn.setColor(Color.RED); btnUp.setTouchable(Touchable.disabled); btnDown.setTouchable(Touchable.disabled); btnLeft.setTouchable(Touchable.disabled); btnRight.setTouchable(Touchable.disabled); btnZoomIn.setTouchable(Touchable.disabled); btnZoomOut.setTouchable(Touchable.disabled); btnBack.setTouchable(Touchable.disabled); setControls(btnZoomIn); } else if (btnZoomOut.isChecked()) { btnZoomOut.setColor(Color.RED); btnUp.setTouchable(Touchable.disabled); btnDown.setTouchable(Touchable.disabled); btnLeft.setTouchable(Touchable.disabled); btnRight.setTouchable(Touchable.disabled); btnZoomIn.setTouchable(Touchable.disabled); btnZoomOut.setTouchable(Touchable.disabled); btnBack.setTouchable(Touchable.disabled); setControls(btnZoomOut); } ///Settings sound.setVolume(game.getMusicVolume()); ///Cursor Pixmap pm = new Pixmap(Gdx.files.internal("img/cursor.png")); Gdx.input.setCursorImage(pm, 0, 0); pm.dispose(); ///Draw Background batch.setProjectionMatrix(camera.combined); batch.begin(); batch.draw(background, 0, 0, Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getHeight()); batch.end(); ///Draw Stage stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); stage.draw(); }
From source file:awakening.view.menu.Graphics.java
License:Apache License
@Override public void render(float delta) { Gdx.gl.glClearColor(0, 0, 0, 1);/*w w w . j a va 2 s . co m*/ Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); Gdx.graphics.setDisplayMode(game.getSize().width, game.getSize().height, game.isFullscreen()); ///Settings sound.setVolume(game.getMusicVolume()); game.setSize(slbResolutions.getSelected().width, slbResolutions.getSelected().height); if (!cbxFullscreen.isChecked() && !Gdx.app.getGraphics().isFullscreen()) { game.setFullscreen(false); Gdx.graphics.setDisplayMode(game.getSize().width, game.getSize().height, false); resize(game.getSize().width, game.getSize().height); } else if (!cbxFullscreen.isChecked() && Gdx.app.getGraphics().isFullscreen()) { game.setFullscreen(false); Gdx.graphics.setDisplayMode(game.getSize().width, game.getSize().height, false); resize(game.getSize().width, game.getSize().height); } else if (cbxFullscreen.isChecked()) { game.setFullscreen(true); Gdx.graphics.setDisplayMode(game.getSize().width, game.getSize().height, true); resize(game.getSize().width, game.getSize().height); } ///Cursor Pixmap pm = new Pixmap(Gdx.files.internal("img/cursor.png")); Gdx.input.setCursorImage(pm, 0, 0); pm.dispose(); ///Draw Background batch.setProjectionMatrix(camera.combined); batch.begin(); batch.draw(background, 0, 0, Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getHeight()); batch.end(); ///Draw Stage stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); stage.draw(); }
From source file:awakening.view.menu.MainMenu.java
License:Apache License
@Override public void render(float delta) { Gdx.gl.glClearColor(0, 0, 0, 1);/*w w w .java2s .c om*/ Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); Gdx.graphics.setDisplayMode(game.getSize().width, game.getSize().height, game.isFullscreen()); ///Settings music.setVolume(game.getMusicVolume()); ///Cursor Skin Pixmap pm = new Pixmap(Gdx.files.internal("img/cursor.png")); Gdx.input.setCursorImage(pm, 0, 0); pm.dispose(); ///Draw Background batch.setProjectionMatrix(camera.combined); batch.begin(); batch.draw(background, 0, 0, Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getHeight()); batch.end(); ///Draw Stage stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); stage.draw(); }
From source file:awakening.view.menu.MapSelection.java
License:Apache License
@Override public void render(float delta) { Gdx.gl.glClearColor(0, 0, 0, 1);/*from w w w . j a v a2 s . c om*/ Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); Gdx.graphics.setDisplayMode(game.getSize().width, game.getSize().height, game.isFullscreen()); ///Settings effect.setVolume(0, game.getSoundVolume()); sound.setVolume(game.getMusicVolume()); ///Cursor Pixmap pm = new Pixmap(Gdx.files.internal("img/cursor.png")); Gdx.input.setCursorImage(pm, 0, 0); pm.dispose(); ///Draw Background batch.setProjectionMatrix(camera.combined); batch.begin(); batch.draw(background, 0, 0, Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getHeight()); batch.end(); ///Draw Stage stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); stage.draw(); }
From source file:awakening.view.menu.Options.java
License:Apache License
@Override public void render(float delta) { Gdx.gl.glClearColor(0, 0, 0, 1);/*from ww w. j a va2 s . c om*/ Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); Gdx.graphics.setDisplayMode(game.getSize().width, game.getSize().height, game.isFullscreen()); ///Settings sound.setVolume(game.getMusicVolume()); ///Cursor Pixmap pm = new Pixmap(Gdx.files.internal("img/cursor.png")); Gdx.input.setCursorImage(pm, 0, 0); pm.dispose(); ///Draw Background batch.setProjectionMatrix(camera.combined); batch.begin(); batch.draw(background, 0, 0, Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getHeight()); batch.end(); ///Draw Stage stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); stage.draw(); }
From source file:base.Engine.java
License:Open Source License
public static Texture generatePatternTexture(PatternEntry basedOn, Color color) { Pixmap px = generatePatternPixmap(basedOn, color); Texture tx = new Texture(px); px.dispose(); return tx;/*from w w w .j a v a2 s . c o m*/ }