Example usage for com.badlogic.gdx.graphics Pixmap Pixmap

List of usage examples for com.badlogic.gdx.graphics Pixmap Pixmap

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics Pixmap Pixmap.

Prototype

public Pixmap(Gdx2DPixmap pixmap) 

Source Link

Document

Constructs a new Pixmap from a Gdx2DPixmap .

Usage

From source file:at.tugraz.ist.catroid.content.Costume.java

License:Open Source License

protected void checkImageChanged() {
    imageLock.acquireUninterruptibly();//from  ww  w.  j  a  v  a 2  s  . c o 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: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 a2 s.com
    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 . j a 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  ava2s .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
    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);//from w ww.j ava2  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());

    ///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  a  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
    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);/*www  . j  a  v a2  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());

    ///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:com.a2client.Cursor.java

License:Open Source License

public void setCursor(String name) {
    if (Utils.isEmpty(name))
        name = "arrow";

    FileHandle file = Gdx.files.internal(CURSORS_DIR + name + ".png");
    if (!file.file().exists()) {
        setCursor("");
        return;/*from   w ww .j  a va  2 s.co m*/
    }

    CursorData fd = null;
    for (CursorData data : _cursors) {
        if (data.name.equalsIgnoreCase(name)) {
            fd = data;
        }
    }

    Pixmap pm = new Pixmap(file);
    com.badlogic.gdx.graphics.Cursor cursor = Gdx.graphics.newCursor(pm, fd != null ? fd.x : 0,
            fd != null ? fd.y : 0);
    Gdx.graphics.setCursor(cursor);
    pm.dispose();
}

From source file:com.austinerb.project0.engine.SpriterLoader.java

License:Apache License

@Override
public void load(final Reference ref, String path) {
    FileHandle f;//from w w  w . j av a 2 s.  c  o  m
    switch (Gdx.app.getType()) {
    case iOS:
        f = Gdx.files.absolute(path);
        break;
    default:
        f = Gdx.files.internal(path);
        break;
    }

    if (!f.exists())
        throw new GdxRuntimeException("Could not find file handle " + path + "! Please check your paths.");
    if (this.packer == null && this.pack)
        this.packer = new PixmapPacker(this.atlasWidth, this.atlasHeight, Pixmap.Format.RGBA8888, 2, true);
    final Pixmap pix = new Pixmap(f);
    this.files.put(ref, null);
    this.pixmaps.put(ref, pix);
}

From source file:com.digitale.screens.MissionScreen.java

License:Open Source License

public Texture generateDynamicTexture(String iconFilename, String category, int quality) {
    Pixmap baseImage;/*  ww w.j  ava2s .  co m*/
    if (category.equals("blueprint")) {
        FileHandle baseFile = Gdx.files.internal("data/blueprint.png");
        baseImage = new Pixmap(baseFile);
    } else {
        baseImage = new Pixmap(64, 64, Format.RGBA8888);
    }
    FileHandle iconFile = Gdx.files.internal(iconFilename);
    FileHandle iconGlowFile = Gdx.files.internal(iconFilename);

    if (Stardust3d.DEEPDEBUG)
        System.out.println("base format" + baseImage.getFormat());
    Pixmap imgA = new Pixmap(iconGlowFile);
    if (Stardust3d.DEEPDEBUG)
        System.out.println("a format" + imgA.getFormat());
    Pixmap imgB = new Pixmap(iconFile);

    if (Stardust3d.DEEPDEBUG)
        System.out.println("b " + iconFilename + " format" + imgB.getFormat());
    // overdraw rectangle to tint icon where needed
    // if(tintcolour !null){imgB.SetColor(tintcolour);

    imgB.fillRectangle(0, 0, 64, 64);

    // set colour for quality marker
    switch (quality) {
    case 0:
        imgB.setColor(.5f, .5f, .5f, 1f);
        break;
    case 1:
        imgB.setColor(.75f, .75f, .75f, 1f);
        break;
    case 2:
        imgB.setColor(1f, 1f, 1f, 1f);
        break;
    case 3:
        imgB.setColor(0f, .5f, 0f, 1f);
        break;
    case 4:
        imgB.setColor(0f, 1f, 0f, 1f);
        break;
    case 5:
        imgB.setColor(0f, 0f, 1f, 1f);
        break;
    case 6:
        imgB.setColor(0f, 0f, .5f, 1f);
        break;
    case 7:
        imgB.setColor(.5f, 0f, 1f, 1f);
        break;
    case 8:
        imgB.setColor(1f, .5f, 0f, 1f);
        break;
    case 9:
        imgB.setColor(1f, 0.5f, 0f, 1f);
        break;
    }
    // draw quality indicator
    imgB.fillRectangle(0, 54, 10, 10);
    baseImage.setColor(0f, 1f, 0f, .2f);
    // baseImage.drawPixmap(imgA, 0, 0, 64, 64, 0, 0, 64, 64);
    // superimpose item's icon
    baseImage.drawPixmap(imgB, 0, 0, 64, 64, 0, 0, 64, 64);
    Texture dynamicTexture = new Texture(baseImage);

    baseImage.dispose();
    imgA.dispose();
    imgB.dispose();

    return dynamicTexture;
}