Examples of TGAHeader


Examples of info.ata4.util.io.image.tga.TGAHeader

        setOutputFileExtension("pkm");
        writeData(res);
    }

    private void extractTGA() throws IOException {
        TGAHeader header = new TGAHeader();
       
        switch (tex.textureFormat) {
            case Alpha8:
                header.imageType = 3;
                header.pixelDepth = 8;
                break;

            case RGBA32:
            case ARGB32:
            case BGRA32:
            case RGBA4444:
            case ARGB4444:
                header.imageType = 2;
                header.pixelDepth = 32;
                break;

            case RGB24:
            case RGB565:
                header.imageType = 2;
                header.pixelDepth = 24;
                break;

            default:
                throw new IllegalStateException("Invalid texture format for TGA: " + tex.textureFormat);
        }
       
        convertToRGBA32();
       
        ByteBuffer bb = tex.imageBuffer;

        int mipMapCount = 1;
       
        if (tex.mipMap) {
            mipMapCount = getMipMapCount(tex.width, tex.height);
        }
       
        for (int i = 0; i < tex.imageCount; i++) {
            header.imageWidth = tex.width;
            header.imageHeight = tex.height;
           
            for (int j = 0; j < mipMapCount; j++) {
                int imageSize = header.imageWidth * header.imageHeight * header.pixelDepth / 8;
               
                if (tgaSaveMipMaps || j == 0) {
                    ByteBuffer bbTga = ByteBuffer.allocateDirect(TGAHeader.SIZE + imageSize);
                    bbTga.order(ByteOrder.LITTLE_ENDIAN);

                    // write TGA header
                    DataOutputWriter out = DataOutputWriter.newWriter(bbTga);
                    header.write(out);

                    // write image data
                    bb.limit(bb.position() + imageSize);
                    bbTga.put(bb);
                    bb.limit(bb.capacity());
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.