当前位置: 首页>>代码示例>>Java>>正文


Java Format类代码示例

本文整理汇总了Java中de.matthiasmann.twl.utils.PNGDecoder.Format的典型用法代码示例。如果您正苦于以下问题:Java Format类的具体用法?Java Format怎么用?Java Format使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Format类属于de.matthiasmann.twl.utils.PNGDecoder包,在下文中一共展示了Format类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: decodeTextureFile

import de.matthiasmann.twl.utils.PNGDecoder.Format; //导入依赖的package包/类
protected static TextureData decodeTextureFile(MyFile file) {
	int width = 0;
	int height = 0;
	ByteBuffer buffer = null;
	try {
		InputStream in = file.getInputStream();
		PNGDecoder decoder = new PNGDecoder(in);
		width = decoder.getWidth();
		height = decoder.getHeight();
		buffer = ByteBuffer.allocateDirect(4 * width * height);
		decoder.decode(buffer, width * 4, Format.BGRA);
		buffer.flip();
		in.close();
	} catch (Exception e) {
		e.printStackTrace();
		System.err.println("Tried to load texture " + file.getName() + " , didn't work");
		System.exit(-1);
	}
	return new TextureData(buffer, width, height);
}
 
开发者ID:TheThinMatrix,项目名称:OpenGL-Animation,代码行数:21,代码来源:TextureUtils.java

示例2: decodeTextureFile

import de.matthiasmann.twl.utils.PNGDecoder.Format; //导入依赖的package包/类
private TextureData decodeTextureFile(String fileName) {
    int width = 0;
    int height = 0;
    ByteBuffer buffer = null;
    try {
        FileInputStream in = new FileInputStream(fileName);
        PNGDecoder decoder = new PNGDecoder(in);
        width = decoder.getWidth();
        height = decoder.getHeight();
        buffer = ByteBuffer.allocateDirect(4 * width * height);
        decoder.decode(buffer, width * 4, Format.RGBA);
        buffer.flip();
        in.close();
    } catch (Exception e) {
        e.printStackTrace();
        System.err.println("Tried to load texture " + fileName + ", didn't work");
        System.exit(-1);
    }
    return new TextureData(buffer, width, height);
}
 
开发者ID:MrManiacc,项目名称:3d-Engine,代码行数:21,代码来源:Loader.java

示例3: decodeTextureFile

import de.matthiasmann.twl.utils.PNGDecoder.Format; //导入依赖的package包/类
private TextureData decodeTextureFile(String fileName) {
	int width = 0;
	int height = 0;
	ByteBuffer buffer = null;
	try {
		PNGDecoder decoder = new PNGDecoder(net.gogo98901.util.Loader.getResourceAsStream(fileName));
		width = decoder.getWidth();
		height = decoder.getHeight();
		buffer = ByteBuffer.allocateDirect(4 * width * height);
		decoder.decode(buffer, width * 4, Format.RGBA);
		buffer.flip();
	} catch (Exception e) {
		Log.severe("Failed to load texture '" + fileName + "'");
		Log.stackTrace(Level.SEVERE, e);

		System.exit(0);
	}
	return new TextureData(buffer, width, height);
}
 
开发者ID:roryclaasen,项目名称:sandbox,代码行数:20,代码来源:Loader.java

示例4: decodeTextureFile

import de.matthiasmann.twl.utils.PNGDecoder.Format; //导入依赖的package包/类
private TextureData decodeTextureFile(String fileName) {
	int width = 0;
	int height = 0;
	ByteBuffer buffer = null;
	try {
		FileInputStream in = new FileInputStream(fileName);
		PNGDecoder decoder = new PNGDecoder(in);
		width = decoder.getWidth();
		height = decoder.getHeight();
		buffer = ByteBuffer.allocateDirect(4 * width * height);
		decoder.decode(buffer, width * 4, Format.RGBA);
		buffer.flip();
		in.close();
	} catch (Exception e) {
		e.printStackTrace();
		System.err.println("Tried to load texture " + fileName + ", didn't work");
		System.exit(-1);
	}
	return new TextureData(buffer, width, height);
}
 
开发者ID:Radseq,项目名称:Mystic-Bastion,代码行数:21,代码来源:Loader.java

示例5: Texture

import de.matthiasmann.twl.utils.PNGDecoder.Format; //导入依赖的package包/类
public Texture(InputStream is) throws Exception {
    try {
        // Load Texture file
        PNGDecoder decoder = new PNGDecoder(is);

        this.width = decoder.getWidth();
        this.height = decoder.getHeight();

        // Load texture contents into a byte buffer
        ByteBuffer buf = ByteBuffer.allocateDirect(4 * decoder.getWidth() * decoder.getHeight());
        decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA);
        buf.flip();

        // Create a new OpenGL texture 
        this.id = glGenTextures();
        // Bind the texture
        glBindTexture(GL_TEXTURE_2D, this.id);

        // Tell OpenGL how to unpack the RGBA bytes. Each component is 1 byte size
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        // Upload the texture data
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this.width, this.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
        // Generate Mip Map
        glGenerateMipmap(GL_TEXTURE_2D);

        is.close();
    } finally {
        if (is != null) {
            is.close();
        }
    }
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:36,代码来源:Texture.java

示例6: loadTexture

import de.matthiasmann.twl.utils.PNGDecoder.Format; //导入依赖的package包/类
private static int loadTexture(String fileName) throws Exception {
    // Load Texture file
    PNGDecoder decoder = new PNGDecoder(Texture.class.getResourceAsStream(fileName));

    // Load texture contents into a byte buffer
    ByteBuffer buf = ByteBuffer.allocateDirect(
            4 * decoder.getWidth() * decoder.getHeight());
    decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA);
    buf.flip();

    // Create a new OpenGL texture 
    int textureId = glGenTextures();
    // Bind the texture
    glBindTexture(GL_TEXTURE_2D, textureId);

    // Tell OpenGL how to unpack the RGBA bytes. Each component is 1 byte size
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    // Upload the texture data
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, decoder.getWidth(), decoder.getHeight(), 0,
            GL_RGBA, GL_UNSIGNED_BYTE, buf);
    // Generate Mip Map
    glGenerateMipmap(GL_TEXTURE_2D);
    return textureId;
}
 
开发者ID:adamegyed,项目名称:endless-hiker,代码行数:29,代码来源:Texture.java

示例7: loadTexture

import de.matthiasmann.twl.utils.PNGDecoder.Format; //导入依赖的package包/类
private static int loadTexture(String fileName) throws Exception {
    // Load Texture file
    PNGDecoder decoder = new PNGDecoder(Texture.class.getResourceAsStream(fileName));

    // Load texture contents into a byte buffer
    ByteBuffer buf = ByteBuffer.allocateDirect(
            4 * decoder.getWidth() * decoder.getHeight());
    decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA);
    buf.flip();

    // Create a new OpenGL texture
    int textureId = glGenTextures();
    // Bind the texture
    glBindTexture(GL_TEXTURE_2D, textureId);

    // Tell OpenGL how to unpack the RGBA bytes. Each component is 1 byte size
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    // Upload the texture data
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, decoder.getWidth(), decoder.getHeight(), 0,
            GL_RGBA, GL_UNSIGNED_BYTE, buf);
    // Generate Mip Map
    glGenerateMipmap(GL_TEXTURE_2D);
    return textureId;
}
 
开发者ID:dwbrite,项目名称:polvo,代码行数:29,代码来源:Texture.java

示例8: Texture

import de.matthiasmann.twl.utils.PNGDecoder.Format; //导入依赖的package包/类
public Texture(InputStream is) throws Exception {
    // Load Texture file
    PNGDecoder decoder = new PNGDecoder(is);

    this.width = decoder.getWidth();
    this.height = decoder.getHeight();

    // Load texture contents into a byte buffer
    ByteBuffer buf = ByteBuffer.allocateDirect(
            4 * decoder.getWidth() * decoder.getHeight());
    decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA);
    buf.flip();

    // Create a new OpenGL texture 
    this.id = glGenTextures();
    // Bind the texture
    glBindTexture(GL_TEXTURE_2D, this.id);

    // Tell OpenGL how to unpack the RGBA bytes. Each component is 1 byte size
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    // Upload the texture data
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this.width, this.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
    // Generate Mip Map
    glGenerateMipmap(GL_TEXTURE_2D);
}
 
开发者ID:lwjglgamedev,项目名称:lwjglbook,代码行数:29,代码来源:Texture.java

示例9: Texture

import de.matthiasmann.twl.utils.PNGDecoder.Format; //导入依赖的package包/类
public Texture(InputStream is) throws Exception {
    try {
        // Load Texture file
        PNGDecoder decoder = new PNGDecoder(is);

        this.width = decoder.getWidth();
        this.height = decoder.getHeight();

        // Load texture contents into a byte buffer
        ByteBuffer buf = ByteBuffer.allocateDirect(
                4 * decoder.getWidth() * decoder.getHeight());
        decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA);
        buf.flip();

        // Create a new OpenGL texture 
        this.id = glGenTextures();
        // Bind the texture
        glBindTexture(GL_TEXTURE_2D, this.id);

        // Tell OpenGL how to unpack the RGBA bytes. Each component is 1 byte size
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        // Upload the texture data
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, this.width, this.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
        // Generate Mip Map
        glGenerateMipmap(GL_TEXTURE_2D);

        is.close();
    } finally {
        if (is != null) {
            is.close();
        }
    }
}
 
开发者ID:lwjglgamedev,项目名称:lwjglbook,代码行数:37,代码来源:Texture.java

示例10: Texture

import de.matthiasmann.twl.utils.PNGDecoder.Format; //导入依赖的package包/类
public Texture(String fileName) throws Exception {

        // Load Texture file
        PNGDecoder decoder = new PNGDecoder(Texture.class.getResourceAsStream(fileName));

        this.width = decoder.getWidth();
        this.height = decoder.getHeight();
        
        // Load texture contents into a byte buffer
        ByteBuffer buf = ByteBuffer.allocateDirect(
                4 * decoder.getWidth() * decoder.getHeight());
        decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA);
        buf.flip();

        // Create a new OpenGL texture 
        int textureId = glGenTextures();
        // Bind the texture
        glBindTexture(GL_TEXTURE_2D, textureId);

        // Tell OpenGL how to unpack the RGBA bytes. Each component is 1 byte size
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        // Upload the texture data
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, decoder.getWidth(), decoder.getHeight(), 0,
                GL_RGBA, GL_UNSIGNED_BYTE, buf);
        // Generate Mip Map
        glGenerateMipmap(GL_TEXTURE_2D);
        
        this.id = textureId;
    }
 
开发者ID:lwjglgamedev,项目名称:lwjglbook,代码行数:33,代码来源:Texture.java


注:本文中的de.matthiasmann.twl.utils.PNGDecoder.Format类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。