本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
}
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
}
}
示例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;
}