Examples of PNGDecoder


Examples of de.matthiasmann.twl.utils.PNGDecoder

        int floorTexture = glGenTextures();
        {
            InputStream in = null;
            try {
                in = new FileInputStream("res/images/floor.png");
                PNGDecoder decoder = new PNGDecoder(in);
                ByteBuffer buffer = BufferUtils.createByteBuffer(4 * decoder.getWidth() * decoder.getHeight());
                decoder.decode(buffer, decoder.getWidth() * 4, Format.RGBA);
                buffer.flip();
                glBindTexture(GL_TEXTURE_2D, floorTexture);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
                glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, decoder.getWidth(), decoder.getHeight(), 0, GL_RGBA,
                        GL_UNSIGNED_BYTE, buffer);
                glBindTexture(GL_TEXTURE_2D, 0);
            } catch (FileNotFoundException ex) {
                System.err.println("Failed to find the texture files.");
                ex.printStackTrace();
View Full Code Here

Examples of de.matthiasmann.twl.utils.PNGDecoder

        int floorTexture = glGenTextures();
        {
            InputStream in = null;
            try {
                in = new FileInputStream("res/images/floor.png");
                PNGDecoder decoder = new PNGDecoder(in);
                ByteBuffer buffer = BufferUtils.createByteBuffer(4 * decoder.getWidth() * decoder.getHeight());
                decoder.decode(buffer, decoder.getWidth() * 4, Format.RGBA);
                buffer.flip();
                glBindTexture(GL_TEXTURE_2D, floorTexture);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
                glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, decoder.getWidth(), decoder.getHeight(), 0, GL_RGBA,
                        GL_UNSIGNED_BYTE, buffer);
                glBindTexture(GL_TEXTURE_2D, 0);
            } catch (FileNotFoundException ex) {
                System.err.println("Failed to find the texture files.");
                Display.destroy();
View Full Code Here

Examples of de.matthiasmann.twl.utils.PNGDecoder

      boolean genMipmap) throws IOException {
    //TODO: npot check
    InputStream input = null;
    try {
      input = pngRef.openStream();
      PNGDecoder dec = new PNGDecoder(input);
     
      width = dec.getWidth();
      height = dec.getHeight();
      ByteBuffer buf = BufferUtils.createByteBuffer(4 * width * height);
      dec.decode(buf, width * 4, PNGDecoder.Format.RGBA);
      buf.flip();
     
      glEnable(getTarget());
      id = glGenTextures();

View Full Code Here

Examples of org.netbeans.jemmy.util.PNGDecoder

    /**
     * Loads an image from a PNG image file.
     */
    public BufferedImage load(String fileName) throws IOException {
        return(new PNGDecoder(new FileInputStream(fileName)).decode());
    }
View Full Code Here

Examples of org.netbeans.jemmy.util.PNGDecoder

    /**
     * Loads an image from a PNG image file.
     */
    public BufferedImage load(String fileName) throws IOException {
        return(new PNGDecoder(new FileInputStream(fileName)).decode());
    }
View Full Code Here

Examples of org.newdawn.slick.opengl.PNGDecoder

        }
        if (pngStream == null) {
            throw new IOException("Missing png to go with texture json");
        }
        try {
            PNGDecoder decoder = new PNGDecoder(pngStream);

            ByteBuffer buf = ByteBuffer.allocateDirect(4 * decoder.getWidth() * decoder.getHeight());
            decoder.decode(buf, decoder.getWidth() * 4, PNGDecoder.RGBA);
            buf.flip();

            ByteBuffer data = buf;
            int height = decoder.getHeight();
            int width = decoder.getWidth();

            Texture.FilterMode filterMode = Texture.FilterMode.NEAREST;
            Texture.WrapMode wrapMode = Texture.WrapMode.CLAMP;
            Texture.Type type = Texture.Type.TEXTURE2D;

View Full Code Here

Examples of org.newdawn.slick.opengl.PNGDecoder

                }
            }

            try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
                ImageIO.write(image, "png", bos);
                PNGDecoder decoder = new PNGDecoder(new ByteArrayInputStream(bos.toByteArray()));
                ByteBuffer buf = ByteBuffer.allocateDirect(4 * decoder.getWidth() * decoder.getHeight());
                decoder.decode(buf, decoder.getWidth() * 4, PNGDecoder.RGBA);
                buf.flip();
                data[i] = buf;
            } catch (IOException e) {
                logger.error("Failed to create atlas texture");
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.