本文整理汇总了Java中com.jme3.texture.Texture2D.getImage方法的典型用法代码示例。如果您正苦于以下问题:Java Texture2D.getImage方法的具体用法?Java Texture2D.getImage怎么用?Java Texture2D.getImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.texture.Texture2D
的用法示例。
在下文中一共展示了Texture2D.getImage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: merge
import com.jme3.texture.Texture2D; //导入方法依赖的package包/类
/**
* This method merges two given textures. The result is stored in the
* 'target' texture.
*
* @param target
* the target texture
* @param source
* the source texture
*/
private void merge(Texture2D target, Texture2D source) {
if (target.getImage().getDepth() != source.getImage().getDepth()) {
throw new IllegalArgumentException("Cannot merge images with different depths!");
}
Image sourceImage = source.getImage();
Image targetImage = target.getImage();
PixelInputOutput sourceIO = PixelIOFactory.getPixelIO(sourceImage.getFormat());
PixelInputOutput targetIO = PixelIOFactory.getPixelIO(targetImage.getFormat());
TexturePixel sourcePixel = new TexturePixel();
TexturePixel targetPixel = new TexturePixel();
int depth = target.getImage().getDepth() == 0 ? 1 : target.getImage().getDepth();
for (int layerIndex = 0; layerIndex < depth; ++layerIndex) {
for (int x = 0; x < sourceImage.getWidth(); ++x) {
for (int y = 0; y < sourceImage.getHeight(); ++y) {
sourceIO.read(sourceImage, layerIndex, sourcePixel, x, y);
targetIO.read(targetImage, layerIndex, targetPixel, x, y);
targetPixel.merge(sourcePixel);
targetIO.write(targetImage, layerIndex, targetPixel, x, y);
}
}
}
}
示例2: scale
import com.jme3.texture.Texture2D; //导入方法依赖的package包/类
/**
* This method scales the given texture to the given size.
*
* @param texture
* the texture to be scaled
* @param width
* new width of the texture
* @param height
* new height of the texture
*/
private void scale(Texture2D texture, int width, int height) {
// first determine if scaling is required
boolean scaleRequired = texture.getImage().getWidth() != width || texture.getImage().getHeight() != height;
if (scaleRequired) {
Image image = texture.getImage();
BufferedImage sourceImage = ImageToAwt.convert(image, false, true, 0);
int sourceWidth = sourceImage.getWidth();
int sourceHeight = sourceImage.getHeight();
BufferedImage targetImage = new BufferedImage(width, height, sourceImage.getType());
Graphics2D g = targetImage.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.drawImage(sourceImage, 0, 0, width, height, 0, 0, sourceWidth, sourceHeight, null);
g.dispose();
Image output = new ImageLoader().load(targetImage, false);
image.setWidth(width);
image.setHeight(height);
image.setData(output.getData(0));
image.setFormat(output.getFormat());
}
}
示例3: RenderImageJme
import com.jme3.texture.Texture2D; //导入方法依赖的package包/类
public RenderImageJme(String filename, boolean linear, NiftyJmeDisplay display){
TextureKey key = new TextureKey(filename, true);
key.setAnisotropy(0);
key.setAsCube(false);
key.setGenerateMips(false);
texture = (Texture2D) display.getAssetManager().loadTexture(key);
texture.setMagFilter(MagFilter.Bilinear);
texture.setMinFilter(MinFilter.BilinearNoMipMaps);
image = texture.getImage();
width = image.getWidth();
height = image.getHeight();
}
示例4: RenderImageJme
import com.jme3.texture.Texture2D; //导入方法依赖的package包/类
public RenderImageJme(String filename, boolean linear, NiftyJmeDisplay display){
TextureKey key = new TextureKey(filename, true);
key.setAnisotropy(0);
key.setAsCube(false);
key.setGenerateMips(false);
texture = (Texture2D) display.getAssetManager().loadTexture(key);
texture.setMagFilter(linear ? MagFilter.Bilinear : MagFilter.Nearest);
texture.setMinFilter(linear ? MinFilter.BilinearNoMipMaps : MinFilter.NearestNoMipMaps);
image = texture.getImage();
width = image.getWidth();
height = image.getHeight();
}