Package cc.plural.utils

Examples of cc.plural.utils.PNGDecoder


        try {
            // Open the PNG file as an InputStream
            //URL file = ClassLoader.class.getResource(path);

            // Link the PNG decoder to this stream
            PNGDecoder decoder = new PNGDecoder(url.openStream());

            // Get the width and height of the texture
            textureWidth = decoder.getWidth();
            textureHeight = decoder.getHeight();

            // Decode the PNG file in a ByteBuffer
            imageBuffer = ByteBuffer.allocateDirect(4 * decoder.getWidth() * decoder.getHeight());
            decoder.decode(imageBuffer, decoder.getWidth() * 4, PNGDecoder.Format.RGBA);
            imageBuffer.flip();
        } catch (IOException e) {
            throw new RuntimeException("Clean this up:" + e);
        }
    }
View Full Code Here


        try {
            // Open the PNG file as an InputStream
            URL file = ClassLoader.class.getResource(fileName);

            // Link the PNG decoder to this stream
            PNGDecoder decoder = new PNGDecoder(file.openStream());

            // Get the width and height of the texture
            tWidth = decoder.getWidth();
            tHeight = decoder.getHeight();


            // Decode the PNG file in a ByteBuffer
            buf = ByteBuffer.allocateDirect(
                    4 * decoder.getWidth() * decoder.getHeight());
            decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA);
            buf.flip();

        } catch(IOException e) {
            throw new RuntimeException("Clean this up:" + e);
        }
View Full Code Here

TOP

Related Classes of cc.plural.utils.PNGDecoder

Copyright © 2018 www.massapicom. 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.