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


Java Image.getWidth方法代码示例

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


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

示例1: init

import org.newdawn.slick.Image; //导入方法依赖的package包/类
/**
 * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
 */
public void init(GameContainer container) throws SlickException {
	image = new Image("testdata/logo.png");
	
	width = image.getWidth() / 3;
	height = image.getHeight() / 3;
	
	images = new Image[] {
			image.getSubImage(0, 0, width, height), image.getSubImage(width,0,width,height), image.getSubImage(width*2,0,width,height),
			image.getSubImage(0, height, width, height), image.getSubImage(width,height,width,height), image.getSubImage(width*2,height,width,height),
			image.getSubImage(0, height*2, width, height), image.getSubImage(width,height*2,width,height), image.getSubImage(width*2,height*2,width,height),
	};
	
	images[0].setColor(Image.BOTTOM_RIGHT, 0,1,1,1);
	images[1].setColor(Image.BOTTOM_LEFT, 0,1,1,1);
	images[1].setColor(Image.BOTTOM_RIGHT, 0,1,1,1);
	images[2].setColor(Image.BOTTOM_LEFT, 0,1,1,1);
	images[3].setColor(Image.TOP_RIGHT, 0,1,1,1);
	images[3].setColor(Image.BOTTOM_RIGHT, 0,1,1,1);
	
	images[4].setColor(Image.TOP_RIGHT, 0,1,1,1);
	images[4].setColor(Image.TOP_LEFT, 0,1,1,1);
	images[4].setColor(Image.BOTTOM_LEFT, 0,1,1,1);
	images[4].setColor(Image.BOTTOM_RIGHT, 0,1,1,1);
	images[5].setColor(Image.TOP_LEFT, 0,1,1,1);
	images[5].setColor(Image.BOTTOM_LEFT, 0,1,1,1);
	
	images[6].setColor(Image.TOP_RIGHT, 0,1,1,1);
	images[7].setColor(Image.TOP_RIGHT, 0,1,1,1);
	images[7].setColor(Image.TOP_LEFT, 0,1,1,1);
	images[8].setColor(Image.TOP_LEFT, 0,1,1,1);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:35,代码来源:ImageCornerTest.java

示例2: LocatedImage

import org.newdawn.slick.Image; //导入方法依赖的package包/类
/**
 * Create a new located image
 * 
 * @param image The image to be drawn
 * @param x The x location at which the image should be drawn
 * @param y The y location at which the image should be drawn
 */
public LocatedImage(Image image, int x, int y) {
	this.image = image;
	this.x = x;
	this.y = y;
	this.width = image.getWidth();
	this.height = image.getHeight();
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:15,代码来源:LocatedImage.java

示例3: render

import org.newdawn.slick.Image; //导入方法依赖的package包/类
@Override
public void render(Graphics g, long cTime) {
	Image icon = getIcon();
	if(isActive(cTime) && (icon != null)) {
		float x = position.x - (icon.getWidth() / 2);
		float y = position.y - (icon.getHeight() / 2);
		g.drawImage(icon, x, y);
	}
}
 
开发者ID:packetpirate,项目名称:Generic-Zombie-Shooter-Redux,代码行数:10,代码来源:Item.java

示例4: isTouching

import org.newdawn.slick.Image; //导入方法依赖的package包/类
public boolean isTouching(double distance) {
	Image icon = getIcon();
	if(icon != null) {
		float width = icon.getWidth();
		float height = icon.getHeight();
		return (distance <= ((width + height) / 2));
	} else return false;
}
 
开发者ID:packetpirate,项目名称:Generic-Zombie-Shooter-Redux,代码行数:9,代码来源:Item.java

示例5: saveImage

import org.newdawn.slick.Image; //导入方法依赖的package包/类
/**
 * @see org.newdawn.slick.imageout.ImageWriter#saveImage(org.newdawn.slick.Image, java.lang.String, java.io.OutputStream, boolean)
 */
public void saveImage(Image image, String format, OutputStream output, boolean writeAlpha) throws IOException {
	DataOutputStream out = new DataOutputStream(new BufferedOutputStream(output));

	// ID Length
	out.writeByte((byte) 0);

	// Color Map
	out.writeByte((byte) 0);

	// Image Type
	out.writeByte((byte) 2);

	// Color Map - Ignored
	out.writeShort(flipEndian((short) 0));
	out.writeShort(flipEndian((short) 0));
	out.writeByte((byte) 0);

	// X, Y Offset
	out.writeShort(flipEndian((short) 0));
	out.writeShort(flipEndian((short) 0));

	// Width, Height, Depth
	out.writeShort(flipEndian((short) image.getWidth()));
	out.writeShort(flipEndian((short) image.getHeight()));
	if (writeAlpha) {
		out.writeByte((byte) 32);
		// Image Descriptor (can't be 0 since we're using 32-bit TGAs)
		// needs to not have 0x20 set to indicate it's not a flipped image
		out.writeByte((byte) 1);
	} else {
		out.writeByte((byte) 24);
		// Image Descriptor (must be 0 since we're using 24-bit TGAs)
		// needs to not have 0x20 set to indicate it's not a flipped image
		out.writeByte((byte) 0);
	}
	

	// Write out the image data
	Color c;

	for (int y = image.getHeight()-1; y <= 0; y--) {
		for (int x = 0; x < image.getWidth(); x++) {
			c = image.getColor(x, y);

			out.writeByte((byte) (c.b * 255.0f));
			out.writeByte((byte) (c.g * 255.0f));
			out.writeByte((byte) (c.r * 255.0f));
			if (writeAlpha) {
				out.writeByte((byte) (c.a * 255.0f));
			}
		}
	}

	out.close();
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:59,代码来源:TGAWriter.java

示例6: MouseOverArea

import org.newdawn.slick.Image; //导入方法依赖的package包/类
/**
 * Create a new mouse over area
 * 
 * @param container
 *            The container displaying the mouse over area
 * @param image
 *            The normalImage to display
 * @param x
 *            The position of the area
 * @param y
 *            the position of the area
 * @param listener
 *            A listener to add to the area
 */
public MouseOverArea(GUIContext container, Image image, int x, int y, ComponentListener listener) {
	this(container, image, x, y, image.getWidth(), image.getHeight());
	addListener(listener);
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:19,代码来源:MouseOverArea.java


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