本文整理汇总了Java中org.newdawn.slick.opengl.LoadableImageData类的典型用法代码示例。如果您正苦于以下问题:Java LoadableImageData类的具体用法?Java LoadableImageData怎么用?Java LoadableImageData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LoadableImageData类属于org.newdawn.slick.opengl包,在下文中一共展示了LoadableImageData类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import org.newdawn.slick.opengl.LoadableImageData; //导入依赖的package包/类
/**
* Create a new big image by loading it from the specified reference
*
* @param ref The reference to the image to load
* @param filter The image filter to apply (@see #Image.FILTER_NEAREST)
* @param tileSize The maximum size of the tiles to use to build the bigger image
* @throws SlickException Indicates we were unable to locate the resource
*/
private void build(String ref, int filter, int tileSize) throws SlickException {
try {
final LoadableImageData data = ImageDataFactory.getImageDataFor(ref);
final ByteBuffer imageBuffer = data.loadImage(ResourceLoader.getResourceAsStream(ref), false, null);
build(data, imageBuffer, filter, tileSize);
} catch (IOException e) {
throw new SlickException("Failed to load: "+ref, e);
}
}
示例2: run
import org.newdawn.slick.opengl.LoadableImageData; //导入依赖的package包/类
@Override
public void run() {
// load image data into a ByteBuffer to use constructor Image(ImageData)
LoadableImageData imageData = ImageDataFactory.getImageDataFor(file.getAbsolutePath());
try (BufferedInputStream in = this.in = new BufferedInputStream(new FileInputStream(file))) {
ByteBuffer textureBuffer = imageData.loadImage(in, false, null);
if (!isInterrupted())
data = new LoadedImageData(imageData, textureBuffer);
} catch (Exception e) {
if (!isInterrupted())
Log.warn(String.format("Failed to load background image '%s'.", file), e);
}
this.in = null;
}
示例3: run
import org.newdawn.slick.opengl.LoadableImageData; //导入依赖的package包/类
@Override
public void run() {
// load image data into a ByteBuffer to use constructor Image(ImageData)
LoadableImageData imageData = ImageDataFactory.getImageDataFor(file.getAbsolutePath());
try (BufferedInputStream in = this.in = new BufferedInputStream(new FileInputStream(file))) {
ByteBuffer textureBuffer = imageData.loadImage(in, false, null);
if (!isInterrupted())
data = new LoadedImageData(imageData, textureBuffer);
} catch (IOException e) {
if (!isInterrupted())
Log.warn(String.format("Failed to load background image '%s'.", file), e);
}
this.in = null;
}
示例4: work
import org.newdawn.slick.opengl.LoadableImageData; //导入依赖的package包/类
@Override
public Object[] work(String resourceKey) throws PromiseException
{
// avoid the resource cache, AsyncTextureLoader has its own cache
InputStream in = db.getInputStreamSync(resourceKey);
ResourceDB.FileEntry fileEntry = db.getFileEntry(resourceKey);
if (in == null || fileEntry == null)
{
log.log(Level.SEVERE, "Unable to load texture, the given resource key ({0}) does not exist", resourceKey);
throw new InvalidResourceKeyException();
}
String fileName = fileEntry.zipEntry == null ? fileEntry.file.getName() : fileEntry.zipEntry;
LoadableImageData imageData = ImageDataFactory.getImageDataFor(fileName);
try
{
ByteBuffer textureBytes = imageData.loadImage(new BufferedInputStream(in), false, null);
if (textureBytes == null)
{
throw new IOException("loadImage returned null");
}
log.log(Level.INFO, "Texture data for {0} read. {1} {2} {3} {4} {5}", new Object[] {
resourceKey,
imageData.getWidth(),
imageData.getHeight(),
imageData.getDepth(),
imageData.getTexWidth(),
imageData.getTexHeight()
});
return new Object[] {
textureBytes,
imageData.getWidth(),
imageData.getHeight(),
imageData.getDepth(),
imageData.getTexWidth(),
imageData.getTexHeight()
};
}
catch (IOException | UnsatisfiedLinkError | UnsupportedOperationException ex)
{
log.log(Level.SEVERE, "Exception while parsing image for texture " + resourceKey, ex);
throw new PromiseException(ex);
}
}
示例5: BigImage
import org.newdawn.slick.opengl.LoadableImageData; //导入依赖的package包/类
/**
* Create a new big image by loading it from the specified image data
*
* @param data The pixelData to use to create the image
* @param imageBuffer The buffer containing texture data
* @param filter The image filter to apply (@see #Image.FILTER_NEAREST)
*/
public BigImage(LoadableImageData data, ByteBuffer imageBuffer, int filter) {
build(data, imageBuffer, filter, getMaxSingleImageSize());
}