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


Java Texture2D.getImage方法代码示例

本文整理汇总了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);
            }
        }
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:33,代码来源:CombinedTexture.java

示例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());
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:36,代码来源:CombinedTexture.java

示例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();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:16,代码来源:RenderImageJme.java

示例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();
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:16,代码来源:RenderImageJme.java


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