當前位置: 首頁>>代碼示例>>Java>>正文


Java Image.getColor方法代碼示例

本文整理匯總了Java中org.newdawn.slick.Image.getColor方法的典型用法代碼示例。如果您正苦於以下問題:Java Image.getColor方法的具體用法?Java Image.getColor怎麽用?Java Image.getColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.newdawn.slick.Image的用法示例。


在下文中一共展示了Image.getColor方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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/testcard.png");
	read[0] = image.getColor(0, 0);
	read[1] = image.getColor(30, 40);
	read[2] = image.getColor(55, 70);
	read[3] = image.getColor(80, 90);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:11,代碼來源:ImageReadTest.java

示例2: isCollision

import org.newdawn.slick.Image; //導入方法依賴的package包/類
private boolean isCollision(float x, float y) {
	int tileW = this.map.getTileWidth();
	int tileH = this.map.getTileHeight();
	int logicLayer = this.map.getLayerIndex("obstacles");
	Image tile = this.map.getTileImage((int) x / tileW, (int) y / tileH, logicLayer);
	boolean collision = tile != null;
	if (collision) {
		Color color = tile.getColor((int) x % tileW, (int) y % tileH);
		collision = color.getAlpha() > 0;
	}
	return collision;
}
 
開發者ID:EnzoMolion,項目名稱:Projet-PLA,代碼行數:13,代碼來源:WindowGame.java

示例3: 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


注:本文中的org.newdawn.slick.Image.getColor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。