本文整理汇总了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);
}
示例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;
}
示例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();
}