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


Java BufferedImageUtil.getTexture方法代码示例

本文整理汇总了Java中org.newdawn.slick.util.BufferedImageUtil.getTexture方法的典型用法代码示例。如果您正苦于以下问题:Java BufferedImageUtil.getTexture方法的具体用法?Java BufferedImageUtil.getTexture怎么用?Java BufferedImageUtil.getTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.newdawn.slick.util.BufferedImageUtil的用法示例。


在下文中一共展示了BufferedImageUtil.getTexture方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: destroy

import org.newdawn.slick.util.BufferedImageUtil; //导入方法依赖的package包/类
/** Destroy parts of the Building */
public void destroy(final int x, final int y, final int radius){
    Graphics2D graphic = buf.createGraphics();
    graphic.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR));

    // We don't need a destruction map. This way we could even use different weapons
    // or randomized damage.
    graphic.fillOval( (int) (x - getRenderPosition().x) - radius, (int) (y - getRenderPosition().y) - radius, radius*2, radius*2);

    // NOTE: We are allowed to use an AWT Buffered image, we can even use a graphics draw ontop of the BufferedImage
    // But no Texture Generation, since that will require an OpenGL Context.
    if (!Game.getInstance().isTestMode()) {
        try { slickImg = new org.newdawn.slick.Image(BufferedImageUtil.getTexture(null, buf)); }
        catch (Exception e) { e.printStackTrace();}
    }
}
 
开发者ID:joshimoo,项目名称:Gorillaz,代码行数:17,代码来源:Skyscraper.java

示例2: loadTexture

import org.newdawn.slick.util.BufferedImageUtil; //导入方法依赖的package包/类
public int loadTexture(BufferedImage bi) {
  Texture texture = null;
  try {
    texture = BufferedImageUtil.getTexture("opencv", bi);
  } catch (IOException e) {
    e.printStackTrace();
  }
  int textureID = texture.getTextureID();
  textures.add(textureID);
  return textureID;
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:12,代码来源:Loader.java

示例3: convertImage

import org.newdawn.slick.util.BufferedImageUtil; //导入方法依赖的package包/类
private Image convertImage(String path) throws IOException {
    BufferedImage bufferedImage = ImageIO.read(DuskMoon.class.getResourceAsStream("/"+path));
    Texture texture = BufferedImageUtil.getTexture("", bufferedImage);
    Image image = null;
    try {
        image = new Image(texture.getImageWidth(), texture.getImageHeight());
        image.setTexture(texture);
    } catch (SlickException e) {
        e.printStackTrace();
    }

    return image;
}
 
开发者ID:Korriban,项目名称:DuskMoon,代码行数:14,代码来源:Art.java

示例4: initializeTextures

import org.newdawn.slick.util.BufferedImageUtil; //导入方法依赖的package包/类
/**
 * Used to create the texture to be used on both the player and enemies. Generating this using the 
 * same math as the calculations we used previously (i.e. alpha is based on distance).
 */
public static void initializeTextures()
{
	int iImageWidth = 128;
	int iImageHeight = 128;
	BufferedImage circleImage = new BufferedImage(iImageWidth, iImageHeight, BufferedImage.TYPE_INT_ARGB);
	
	float radius = 64.0f;
 	  
	for(int i = 0; i < circleImage.getWidth(); i++)
	{
		for(int j = 0; j < circleImage.getHeight(); j++)
		{
			float distToCenter = distance[Math.abs((int)(64 - i))][Math.abs((int)(64 - j))];
			float fAlphaMultiplier = Math.abs((1 - (distToCenter / radius)));
		  	
			if(distToCenter > 64.0f)
				fAlphaMultiplier = 0.0f;
		  	  
			circleImage.setRGB(i, j, new java.awt.Color(1.0f, 1.0f, 1.0f, fAlphaMultiplier).getRGB() );
		}
	}
	
	try
	{
		if(texture == null && Display.isCreated())
			texture = BufferedImageUtil.getTexture("enemy", circleImage);
	}
	catch(IOException e)
	{
		System.err.println("Could not load the specified texture.");
		e.printStackTrace();
	}
}
 
开发者ID:Jrokisky,项目名称:Sonance,代码行数:38,代码来源:StaticDrawer.java

示例5: createSet

import org.newdawn.slick.util.BufferedImageUtil; //导入方法依赖的package包/类
/**
 * Create and store the font
 * 
 * @param customCharsArray Characters that should be also added to the cache.
 */
private void createSet( char[] customCharsArray ) {
	// If there are custom chars then I expand the font texture twice		
	if	(customCharsArray != null && customCharsArray.length > 0) {
		textureWidth *= 2;
	}
	
	// In any case this should be done in other way. Texture with size 512x512
	// can maintain only 256 characters with resolution of 32x32. The texture
	// size should be calculated dynamicaly by looking at character sizes. 
	
	try {
		
		BufferedImage imgTemp = new BufferedImage(textureWidth, textureHeight, BufferedImage.TYPE_INT_ARGB);
		Graphics2D g = (Graphics2D) imgTemp.getGraphics();

		g.setColor(new Color(255,255,255,1));
		g.fillRect(0,0,textureWidth,textureHeight);
		
		int rowHeight = 0;
		int positionX = 0;
		int positionY = 0;
		
		int customCharsLength = ( customCharsArray != null ) ? customCharsArray.length : 0; 

		for (int i = 0; i < 256 + customCharsLength; i++) {
			
			// get 0-255 characters and then custom characters
			char ch = ( i < 256 ) ? (char) i : customCharsArray[i-256];
			
			BufferedImage fontImage = getFontImage(ch);

			IntObject newIntObject = new IntObject();

			newIntObject.width = fontImage.getWidth();
			newIntObject.height = fontImage.getHeight();

			if (positionX + newIntObject.width >= textureWidth) {
				positionX = 0;
				positionY += rowHeight;
				rowHeight = 0;
			}

			newIntObject.storedX = positionX;
			newIntObject.storedY = positionY;

			if (newIntObject.height > fontHeight) {
				fontHeight = newIntObject.height;
			}

			if (newIntObject.height > rowHeight) {
				rowHeight = newIntObject.height;
			}

			// Draw it here
			g.drawImage(fontImage, positionX, positionY, null);

			positionX += newIntObject.width;

			if( i < 256 ) { // standard characters
				charArray[i] = newIntObject;
			} else { // custom characters
				customChars.put( new Character( ch ), newIntObject );
			}

			fontImage = null;
		}

		fontTexture = BufferedImageUtil
				.getTexture(font.toString(), imgTemp);

	} catch (IOException e) {
		System.err.println("Failed to create font.");
		e.printStackTrace();
	}
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:81,代码来源:TrueTypeFont.java

示例6: Skyscraper

import org.newdawn.slick.util.BufferedImageUtil; //导入方法依赖的package包/类
/** Construct a skyscraper
 * @param topLeftPos
 * @param buildingWidth
 * @param mapWidth
 * @param mapHeight
 */
public Skyscraper(Vector2f topLeftPos, int buildingWidth, int mapWidth, int mapHeight) {
    super("Skyscaper");
    int height = mapHeight - (int) topLeftPos.y;
    int width = buildingWidth;

    // Translate TopLeft to Center Position
    setPosition(new Vector2f(topLeftPos.x + width / 2, mapHeight - height / 2));
    setSize(new Vector2f(width, height)); // We set the size explicitly since we have no render component

    // Building
    Random r = new Random();
    Color color = new Color(r.nextInt(255), r.nextInt(255), r.nextInt(255));

    // Windows
    int winSize    = 20;                        // Size of a window [px]
    int winColumns = r.nextInt(2) + 3;          // Amount of vertical columns [3-4]
    int winSpacing = width / winColumns;        // Spacing per Column
    int winPadding = (winSpacing - winSize) /2; // Padding per Window
    int winRows    = height / winSpacing;       // Amount of Horizontal rows

    // The image needs an Alpha-component so we can erase some parts of it.
    buf = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = buf.createGraphics();

    /* Draw the Skyscraper Wall */
    g.setColor(color);
    g.fillRect(0, 0, width, height);
    g.setColor(color.darker());
    for(int j = 0; j <= winRows; j++)
        for(int i = 0; i < winColumns; i++)
            g.fillRect( (i*winSpacing) + winPadding, (j*winSpacing) + winPadding, winSize, winSize);


    // NOTE: We are allowed to use an AWT Buffered image, we can even use a graphics draw ontop of the BufferedImage
    // But no Texture Generation, since that will require an OpenGL Context.
    if (!Game.getInstance().isTestMode()) {
        try { slickImg = new org.newdawn.slick.Image(BufferedImageUtil.getTexture(null, buf)); }
        catch (Exception e) { e.printStackTrace();}
    }
}
 
开发者ID:joshimoo,项目名称:Gorillaz,代码行数:47,代码来源:Skyscraper.java


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