• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AWTLoader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: resizeToPowerOf2

import com.jme3.texture.plugins.AWTLoader; //导入依赖的package包/类
public static void resizeToPowerOf2(Image image){
    BufferedImage original = ImageToAwt.convert(image, false, true, 0);
    int potWidth = FastMath.nearestPowerOfTwo(image.getWidth());
    int potHeight = FastMath.nearestPowerOfTwo(image.getHeight());
    int potSize = Math.max(potWidth, potHeight);

    BufferedImage scaled = scaleDown(original, potSize, potSize);

    AWTLoader loader = new AWTLoader();
    Image output = loader.load(scaled, false);

    image.setWidth(potSize);
    image.setHeight(potSize);
    image.setDepth(0);
    image.setData(output.getData(0));
    image.setFormat(output.getFormat());
    image.setMipMapSizes(null);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:19,代码来源:MipMapGenerator.java


示例2: scale

import com.jme3.texture.plugins.AWTLoader; //导入依赖的package包/类
@Override
public void scale(int width, int height) {
       if (width < 0 && height < 0) {
           return;
       } else if (width < 0) {
           width = Math.round(width
                   * (height == 0 ? 1 : ((float) height / height)));
       } else if (height < 0) {
           height = Math.round(height
                   * (width == 0 ? 1 : ((float) width / width)));
       }
       BufferedImage bim = ImageToAwt.convert(image, false, true, 0);
       System.err.println("scaling image from " + image.getWidth() + " x " + image.getHeight() + " to " + width + " x " + height);
       BufferedImage tbim = new BufferedImage(width, height, bim.getType());
       tbim.getGraphics().drawImage(bim, 0, 0, width, height, null);
       image = new AWTLoader().load(tbim, false);
   }
 
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:18,代码来源:XHTMLFSImage.java


示例3: initializeGeometry

import com.jme3.texture.plugins.AWTLoader; //导入依赖的package包/类
@Override
public void initializeGeometry(AssetManager assetManager)
{
	this.assetManager = assetManager;
	quad = new CenteredQuad(100, 100);
	bufferedImage = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
	gfx = (Graphics2D) bufferedImage.getGraphics();
	gfx.setColor(Color.white);
	gfx.fillRect(0, 0, 100, 100);
	quadGeometry = new Geometry("_quad_geom", quad);

	// reminder of where to find j3md stuff: jme3/src/core-data
	mat = new Material(this.assetManager, "Common/MatDefs/Misc/SimpleTextured.j3md");
	mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
	// Texture tex = assetManager.loadTexture("Interface/Logo/Monkey.jpg");
	Image img = new AWTLoader().load(bufferedImage, true);
	t = new Texture2D(img);
	mat.setTexture("m_ColorMap", t);

	quadGeometry.setMaterial(mat);

	ItemMap.register(quadGeometry, this);
	attachChild(quadGeometry);

}
 
开发者ID:synergynet,项目名称:synergynet3.1,代码行数:26,代码来源:JMEKeyboard.java


示例4: generateImage

import com.jme3.texture.plugins.AWTLoader; //导入依赖的package包/类
public void generateImage() {
    BufferedImage image = new BufferedImage(widthResolution, heightResolution, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = image.createGraphics();
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    if (fillColor != null) {
        g.setColor(fillColor);
        g.fillArc((int) borderWidth / 2, (int) borderWidth / 2, (int) (widthResolution - 1 - borderWidth), (int) (heightResolution - borderWidth), 180+(angle/2), -angle);
    }
    g.setStroke(new BasicStroke(borderWidth));
    g.setColor(color);
    g.drawArc((int) borderWidth / 2, (int) borderWidth / 2, (int) (widthResolution - 1 - borderWidth), (int) (heightResolution - borderWidth), 180 +(borderAngle/2), -borderAngle);

    AWTLoader awtLoader = new AWTLoader();
    texture.setImage(awtLoader.load(image, false));
    material.setTexture("ColorMap", texture);
}
 
开发者ID:mifth,项目名称:JME-Simple-Examples,代码行数:17,代码来源:Circle2d.java


示例5: main

import com.jme3.texture.plugins.AWTLoader; //导入依赖的package包/类
public static void main(String[] args){
    AssetManager am = new DesktopAssetManager();

    am.registerLoader(AWTLoader.class.getName(), "png");
    am.registerLoader(WAVLoader.class.getName(), "wav");

    // register absolute locator
    am.registerLocator("/",  ClasspathLocator.class.getName());

    // find a sound
    AudioData audio = am.loadAudio("Sound/Effects/Gun.wav");

    // find a texture
    Texture tex = am.loadTexture("Textures/Terrain/Pond/Pond.png");

    if (audio == null)
        throw new RuntimeException("Cannot find audio!");
    else
        System.out.println("Audio loaded from Sounds/Effects/Gun.wav");

    if (tex == null)
        throw new RuntimeException("Cannot find texture!");
    else
        System.out.println("Texture loaded from Textures/Terrain/Pond/Pond.png");

    System.out.println("Success!");
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:28,代码来源:TestAbsoluteLocators.java


示例6: createImageResource

import com.jme3.texture.plugins.AWTLoader; //导入依赖的package包/类
/**
 * Factory method to generate ImageResources from a given Image. May be
 * overridden in subclass.
 *
 * @param uri The URI for the image, resolved to an absolute URI.
 * @param is Stream of the image; may be null (for example, if image could
 * not be loaded).
 *
 * @return An ImageResource containing the image.
 */
protected ImageResource createImageResource(String uri, InputStream is) {
    try {
        // For any external stuff load an AWT image and convert. I'm not sure how
        // to load a Texture Image directly from a stream
        AWTLoader loader= new AWTLoader();
        Image img = loader.load(is, true);
        return new ImageResource(uri, new XHTMLFSImage(img, this, uri));
    } catch (IOException ex) {
        throw new AssetLoadException("Failed to load image.", ex);
    }
}
 
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:22,代码来源:NaiveUserAgent.java


示例7: reDrawKeyboard

import com.jme3.texture.plugins.AWTLoader; //导入依赖的package包/类
@Override
public void reDrawKeyboard(boolean shiftDown, boolean altDown, boolean ctlDown)
{
	if (this.renderer != null)
	{
		if (gfx != null)
		{
			renderer.drawKeyboard(gfx, shiftDown, altDown, ctlDown);
			Image img2 = new AWTLoader().load(bufferedImage, true);
			mat.setTexture("m_ColorMap", new Texture2D(img2));
		}
	}
}
 
开发者ID:synergynet,项目名称:synergynet3.1,代码行数:14,代码来源:JMEKeyboard.java


示例8: main

import com.jme3.texture.plugins.AWTLoader; //导入依赖的package包/类
public static void main(String[] args){
    AssetManager am = new DesktopAssetManager();

    am.registerLoader(AWTLoader.class.getName(), "jpg");
    am.registerLoader(WAVLoader.class.getName(), "wav");

    // register absolute locator
    am.registerLocator("/",  ClasspathLocator.class.getName());

    // find a sound
    AudioData audio = am.loadAudio("Sound/Effects/Gun.wav");

    // find a texture
    Texture tex = am.loadTexture("Textures/Terrain/Pond/Pond.jpg");

    if (audio == null)
        throw new RuntimeException("Cannot find audio!");
    else
        System.out.println("Audio loaded from Sounds/Effects/Gun.wav");

    if (tex == null)
        throw new RuntimeException("Cannot find texture!");
    else
        System.out.println("Texture loaded from Textures/Terrain/Pond/Pond.jpg");

    System.out.println("Success!");
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:28,代码来源:TestAbsoluteLocators.java


示例9: simpleInitApp

import com.jme3.texture.plugins.AWTLoader; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    if (debug) {
        mouseInput.setCursorVisible(true);
    }
    assetManager.registerLocator(".", FileLocator.class);
    assetManager.registerLoader(BlenderLoader.class, "blend");
    assetManager.registerLoader(AWTLoader.class, "png");

    viewPort.setBackgroundColor(ColorRGBA.Gray);

    flyCam.setMoveSpeed(20);
    cam.setFrustumFar(1000.0f);
    cam.setFrustumNear(1.0f);
    AssetInfo ai = new AssetInfo(assetManager, modelKey) {

        @Override
        public InputStream openStream() {
            try {
                return new FileInputStream(this.key.getName());
            } catch (FileNotFoundException e) {
                LOGGER.log(Level.SEVERE, e.getMessage(), e);
                return null;
            }
        }
    };
    rootNode.attachChild(new Pivot(assetManager));
    if (modelKey instanceof BlenderKey) {
        Node blenderModel = this.testBlenderLoader(ai);
        Map<String, Map<String, int[]>> animations = ((BlenderKey) modelKey).getAnimations();
        //setting the first animation as active
        if (((BlenderKey) modelKey).getAnimations() != null) {
            for (Entry<String, Map<String, int[]>> animEntry : animations.entrySet()) {
                for (Entry<String, int[]> anim : animEntry.getValue().entrySet()) {
                    Spatial animatedSpatial = this.findNode(blenderModel, animEntry.getKey());
                    animatedSpatial.getControl(AnimControl.class).createChannel().setAnim(anim.getKey());
                    break;
                }
                break;
            }
        }
    } else {
        this.testBlenderModelLoader(ai);
    }

    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(0, -10, 0).normalizeLocal());
    sun.setColor(ColorRGBA.White);
    rootNode.addLight(sun);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:51,代码来源:ManualBlenderTester.java


示例10: generateMipMaps

import com.jme3.texture.plugins.AWTLoader; //导入依赖的package包/类
public static void generateMipMaps(Image image){
    BufferedImage original = ImageToAwt.convert(image, false, true, 0);
    int width = original.getWidth();
    int height = original.getHeight();
    int level = 0;

    BufferedImage current = original;
    AWTLoader loader = new AWTLoader();
    ArrayList<ByteBuffer> output = new ArrayList<ByteBuffer>();
    int totalSize = 0;
    Format format = null;
    
    while (height >= 1 || width >= 1){
        Image converted = loader.load(current, false);
        format = converted.getFormat();
        output.add(converted.getData(0));
        totalSize += converted.getData(0).capacity();

        if(height == 1 || width == 1) {
          break;
        }

        level++;

        height /= 2;
        width /= 2;

        current = scaleDown(current, width, height);
    }

    ByteBuffer combinedData = BufferUtils.createByteBuffer(totalSize);
    int[] mipSizes = new int[output.size()];
    for (int i = 0; i < output.size(); i++){
        ByteBuffer data = output.get(i);
        data.clear();
        combinedData.put(data);
        mipSizes[i] = data.capacity();
    }
    combinedData.flip();

    // insert mip data into image
    image.setData(0, combinedData);
    image.setMipMapSizes(mipSizes);
    image.setFormat(format);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:46,代码来源:MipMapGenerator.java


示例11: generateImage

import com.jme3.texture.plugins.AWTLoader; //导入依赖的package包/类
@Override
public void generateImage()
{
	Texture2D tex = new Texture2D(new AWTLoader().load(canvas.getImage(), false));
	image.setTexture(tex);
}
 
开发者ID:synergynet,项目名称:synergynet3.1,代码行数:7,代码来源:PTMViewerItem.java


示例12: initGui

import com.jme3.texture.plugins.AWTLoader; //导入依赖的package包/类
private void initGui() {
    oneGui = new OneGui();

    try (InputStream inputStream = Example1.class.getResourceAsStream("/example1.ogs")) {
        oneGui.addStyles(inputStream);
    } catch (Exception e) {

    }

    final Screen screen = new Screen(oneGui, "screen");
    Panel leftPanel = new Panel(screen, "panelLeft");
    Button startNewGameButton = new Button(leftPanel, "startNewGame");

    startNewGameButton.addClickedEventListener(id -> {
        System.out.println("Clicked: " + id);
    });

    Button showSettingsButton = new Button(leftPanel, "showSettings");

    Panel centerspace = new Panel(screen, "panelCenterSpace");

    Panel rightPanel = new Panel(screen, "panelRight");

    label = new Label(rightPanel, "label1");
    label.setText("SettingslåäöÅÄÖqhjKp");
    Label settingsLabel2 = new Label(rightPanel, "label2");
    settingsLabel2.setText("SettingslåäöÅÄÖqhjKp");
    Label settingsLabel3 = new Label(rightPanel, "label3");
    settingsLabel3.setText("SettingslåäöÅÄÖqhjKp");

    Button button2 = new Button(rightPanel, "saveSettings");

    startNewGameButton.click();

    oneGuiRenderer = new OneGuiRenderer(screen, 1280, 720);
    oneGuiRenderer.update(1);

    final BufferedImage bufferedImage = oneGuiRenderer.generateImage();
    image = new AWTLoader().load(bufferedImage, true);

    final byte[] pixels = ((DataBufferByte) bufferedImage.getRaster().getDataBuffer()).getData();
    flipImage(pixels, (int) oneGuiRenderer.getWidth(), (int) oneGuiRenderer.getHeight(), bufferedImage.getColorModel().getPixelSize());
    byteBuffer = BufferUtils.createByteBuffer(pixels.length);
    byteBuffer.put(pixels);
    byteBuffer.flip();

    texture = new Texture2D(image);
    texture.setAnisotropicFilter(2);
    final Picture picture = new Picture("HUD Picture");
    picture.setWidth(settings.getWidth());
    picture.setHeight(settings.getHeight());
    picture.setPosition(0, 0);
    picture.setTexture(assetManager, texture, true);

    guiNode.attachChild(picture);
}
 
开发者ID:Kendanware,项目名称:onegui,代码行数:57,代码来源:Jme3Example1.java


示例13: awtImageToTexture

import com.jme3.texture.plugins.AWTLoader; //导入依赖的package包/类
public static Texture awtImageToTexture(final BufferedImage img) {
    final AWTLoader loader = new AWTLoader();
    final Texture tex = new Texture2D();
    tex.setImage(loader.load(img, true));
    return tex;
}
 
开发者ID:duodecimo,项目名称:jmcv,代码行数:7,代码来源:Main.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CSQueue类代码示例发布时间:2022-05-22
下一篇:
Java MultiScheme类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap