本文整理匯總了Java中com.badlogic.gdx.graphics.Pixmap.getHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java Pixmap.getHeight方法的具體用法?Java Pixmap.getHeight怎麽用?Java Pixmap.getHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.graphics.Pixmap
的用法示例。
在下文中一共展示了Pixmap.getHeight方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fillFormWithConstantColor
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
public static Pixmap fillFormWithConstantColor(Pixmap pixmap, Color fillColor) {
// set fill color
pixmap.setColor(fillColor);
Color color = new Color();
for (int x = 0; x < pixmap.getWidth(); x++) {
for (int y = 0; y < pixmap.getHeight(); y++) {
int colorInt = pixmap.getPixel(x, y);
color.set(colorInt);
// get color alpha value
float alpha = color.a;
if (alpha > 0) {
pixmap.setColor(fillColor);
pixmap.fillRectangle(x, y, 1, 1);
} else {
pixmap.setColor(new Color(0, 0, 0, 0));
pixmap.fillRectangle(x, y, 1, 1);
}
}
}
return pixmap;
}
示例2: takeScreenshot
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
public static void takeScreenshot() {
Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, Gdx.graphics.getBackBufferWidth(),
Gdx.graphics.getBackBufferHeight());
FileHandle dir = Compatibility.get().getBaseFolder().child("screenshots");
dir.mkdirs();
FileHandle f = dir.child(System.currentTimeMillis() + ".png");
try {
PixmapIO.PNG writer = new PixmapIO.PNG((int) (pixmap.getWidth() * pixmap.getHeight() * 1.5f));
try {
writer.setFlipY(true);
writer.write(f, pixmap);
} finally {
writer.dispose();
}
} catch (IOException ex) {
throw new CubesException("Error writing PNG: " + f, ex);
} finally {
pixmap.dispose();
}
Log.info("Took screenshot '" + f.file().getAbsolutePath() + "'");
}
示例3: takeScreenshot
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
public static void takeScreenshot() {
Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
FileHandle dir = Compatibility.get().getBaseFolder().child("screenshots");
dir.mkdirs();
FileHandle f = dir.child(System.currentTimeMillis() + ".png");
try {
PixmapIO.PNG writer = new PixmapIO.PNG((int) (pixmap.getWidth() * pixmap.getHeight() * 1.5f));
try {
writer.setFlipY(true);
writer.write(f, pixmap);
} finally {
writer.dispose();
}
} catch (IOException ex) {
throw new CubesException("Error writing PNG: " + f, ex);
} finally {
pixmap.dispose();
}
Log.info("Took screenshot '" + f.file().getAbsolutePath() + "'");
}
示例4: verifySize
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
private boolean verifySize(Pixmap pix){
boolean w = false, h = false;
for(int i : MapEditor.validMapSizes){
if(pix.getWidth() == i)
w = true;
if(pix.getHeight() == i)
h = true;
}
return w && h;
}
示例5: verifyMap
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
private boolean verifyMap(){
int psc = ColorMapper.getColor(SpecialBlocks.playerSpawn);
int esc = ColorMapper.getColor(SpecialBlocks.enemySpawn);
int playerSpawns = 0;
int enemySpawns = 0;
Pixmap pix = editor.pixmap();
for(int x = 0; x < pix.getWidth(); x ++){
for(int y = 0; y < pix.getHeight(); y ++){
int i = pix.getPixel(x, y);
if(i == psc) playerSpawns ++;
if(i == esc) enemySpawns ++;
}
}
if(playerSpawns == 0){
Vars.ui.showError("$text.editor.noplayerspawn");
return false;
}else if(playerSpawns > 1){
Vars.ui.showError("$text.editor.manyplayerspawns");
return false;
}
if(enemySpawns > MapEditor.maxSpawnpoints){
Vars.ui.showError(Bundles.format("text.editor.manyenemyspawns", MapEditor.maxSpawnpoints));
return false;
}
return true;
}
示例6: putPixelsBack
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
public static void putPixelsBack(Pixmap pixmap, ByteBuffer pixels) {
if (pixmap.getWidth() == 0 || pixmap.getHeight() == 0) return;
if (imageData == null) {
imageData = pixmap.getContext().createImageData(pixmap.getHeight(), pixmap.getWidth());
}
putPixelsBack(pixels.array(), pixmap.getWidth(), pixmap.getHeight(), pixmap.getContext(), imageData);
}
示例7: gaussianPixmap
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
private static void gaussianPixmap(Pixmap in, Pixmap out, double[][] gwm, int gaussianRadius) {
Color inColor = new Color();
Color outColor = new Color();
int offsetX = (in.getWidth() - out.getWidth()) / 2;
int offsetY = (in.getHeight() - out.getHeight()) / 2;
int width = out.getWidth();
int height = out.height();
for (int x = 0; x < width; x++, width = out.getWidth()) {
for (int y = 0; y < height; y++, height = out.height()) {
outColor.set(0, 0, 0, 0);
for (int ox = -gaussianRadius; ox <= gaussianRadius; ox++) {
for (int oy = -gaussianRadius; oy <= gaussianRadius; oy++) {
int pixel = in.getPixel(x + ox + offsetX, y + oy + offsetY);
inColor.set(pixel);
double d = gwm[ox + gaussianRadius][oy + gaussianRadius];
outColor.r += inColor.r * d;
outColor.g += inColor.g * d;
outColor.b += inColor.b * d;
outColor.a += inColor.a * d;
}
}
out.drawPixel(x, y, Color.rgba8888(outColor.clamp()));
}
}
}
示例8: testRemovedPixmapField
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
public void testRemovedPixmapField(){
GraphHeader.currentReadWriteVersion = 0;
TestClass object = new TestClass();
object.someInt = randInt();
object.someFloat = randFloat();
object.point = new GridPoint2(randInt(), randInt());
object.color = new Color(Color.CYAN);
object.smallTestClass = new SmallTestClass();
object.smallTestClass.someValue = randInt();
Pixmap pixmap = new Pixmap(20, 24, Pixmap.Format.RGBA8888);
for (int i = 0; i < pixmap.getWidth(); i++) {
for (int j = 0; j < pixmap.getHeight(); j++) {
pixmap.drawPixel(i, j, randInt());
}
}
object.smallTestClass.somePixmap = pixmap;
kryo.register(SmallTestClass.class);
kryo.register(TestClass.class);
GraphHeader<TestClass> graphHeader = new GraphHeader<TestClass>();
graphHeader.data = object;
GraphHeader.currentReadWriteVersion = 0;
byte[] written = write(graphHeader);
GraphHeader.currentReadWriteVersion = 1;
GraphHeader<TestClass> returned = read(written, GraphHeader.class);
assertTrue(equals(graphHeader, returned));
assertTrue(returned.data.smallTestClass.somePixmap == null);
}
示例9: blur
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
/**
* This is an implementation of a box blurring algorithm obtained from
* http://blackpawn.com/texts/blur/default.html
* @param img A pixmap which will be blurred
* @param radius The radius of the blur to generate to the image
* @return img, with a box blur of radius = r applied to it
*/
public static Pixmap blur(Pixmap img, int radius) {
Pixmap tmp = new Pixmap(img.getWidth(), img.getHeight(), Pixmap.Format.RGB888);
Pixmap result = new Pixmap(img.getWidth(), img.getHeight(), Pixmap.Format.RGB888);
blurHorizontal(img, tmp, radius);
blurVertical(tmp, result, radius);
tmp.dispose();
return result;
}
示例10: blurHorizontal
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
private static void blurHorizontal(Pixmap src, Pixmap dst, int radius) {
for (int i = 0; i < src.getWidth(); i++) {
for (int j = 0; j < src.getHeight(); j++) {
int r = 0;
int g = 0;
int b = 0;
int count = 0;
for (int x = i - radius; x <= i + radius; x++) {
if (x < 0 || x > src.getWidth()) {
continue;
}
int current = src.getPixel(x, j) >> 8; // dump the alpha value
b += (current & 0xff);
current >>= 8;
g += (current & 0xff);
current >>= 8;
r += (current & 0xff);
count++;
}
r /= count;
g /= count;
b /= count;
dst.drawPixel(i, j, getRGB(r, g, b));
}
}
}
示例11: blurVertical
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
private static void blurVertical(Pixmap src, Pixmap dst, int radius) {
for (int i = 0; i < src.getWidth(); i++) {
for (int j = 0; j < src.getHeight(); j++) {
int r = 0;
int g = 0;
int b = 0;
int count = 0;
for (int y = j - radius; y <= j + radius; y++) {
if (y < 0 || y >= src.getHeight()) {
continue;
}
int current = src.getPixel(i, y) >> 8; // no alpha needed
b += (current & 0xff);
current >>= 8;
g += (current & 0xff);
current >>= 8;
r += (current & 0xff);
count++;
}
r /= count;
g /= count;
b /= count;
dst.drawPixel(i, j, getRGB(r, g, b));
}
}
}
示例12: createTextureFromBytes
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
/**
* Transforms byte[] to Texture Region.
* <p>
* If you are going to call this method inside firebase callback remember to wrap it<p>
* into {@code Gdx.app.postRunnable(Runnable)}.
* The texture will be changed so that it has sides with length of power of 2.
*
* @param bytes Byte array with image description
* @return Texture region representation of given byte array
*/
public static TextureRegion createTextureFromBytes(byte[] bytes)
{
Pixmap pixmap = new Pixmap(bytes, 0, bytes.length);
final int orgWidth = pixmap.getWidth();
final int orgHeight = pixmap.getHeight();
int width = MathUtils.nextPowerOfTwo(orgWidth);
int height = MathUtils.nextPowerOfTwo(orgHeight);
final Pixmap potPixmap = new Pixmap(width, height, pixmap.getFormat());
potPixmap.drawPixmap(pixmap, 0, 0, 0, 0, pixmap.getWidth(), pixmap.getHeight());
pixmap.dispose();
TextureRegion region = new TextureRegion(new Texture(potPixmap), 0, 0, orgWidth, orgHeight);
potPixmap.dispose();
return region;
}
示例13: gaussianPixmap
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
private static void gaussianPixmap(Pixmap in, Pixmap out, double[][] gwm, int gaussianRadius) {
Color inColor = new Color();
Color outColor = new Color();
int offsetX = (in.getWidth() - out.getWidth()) / 2;
int offsetY = (in.getHeight() - out.getHeight()) / 2;
for (int x = 0; x < out.getWidth(); x++) {
for (int y = 0; y < out.getHeight(); y++) {
outColor.set(0, 0, 0, 0);
for (int ox = -gaussianRadius; ox <= gaussianRadius; ox++) {
for (int oy = -gaussianRadius; oy <= gaussianRadius; oy++) {
int pixel = in.getPixel(x + ox + offsetX, y + oy + offsetY);
inColor.set(pixel);
double d = gwm[ox + gaussianRadius][oy + gaussianRadius];
outColor.r += inColor.r * d;
outColor.g += inColor.g * d;
outColor.b += inColor.b * d;
outColor.a += inColor.a * d;
}
}
out.drawPixel(x, y, Color.rgba8888(outColor.clamp()));
}
}
}
示例14: generate
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
/**Returns world size.*/
public static void generate(Pixmap pixmap, Tile[][] tiles){
boolean hasenemies = true, hascore = false;
Noise.setSeed(Vars.world.getSeed());
for(int x = 0; x < pixmap.getWidth(); x ++){
for(int y = 0; y < pixmap.getHeight(); y ++){
Block floor = Blocks.stone;
Block block = Blocks.air;
int color = pixmap.getPixel(x, pixmap.getHeight()-1-y);
BlockPair pair = ColorMapper.get(color);
if(pair != null){
block = pair.wall;
floor = pair.floor;
}
if(block == SpecialBlocks.playerSpawn){
block = Blocks.air;
Vars.control.setCore(Vars.world.tile(x, y));
hascore = true;
}else if(block == SpecialBlocks.enemySpawn){
block = Blocks.air;
Vars.control.addSpawnPoint(Vars.world.tile(x, y));
hasenemies = true;
}
if(block == Blocks.air && Mathf.chance(0.025) && rocks.containsKey(floor)){
block = rocks.get(floor);
}
if(floor == Blocks.stone || floor == Blocks.grass || floor == Blocks.blackstone ||
floor == Blocks.snow || floor == Blocks.sand){
if(Noise.nnoise(x, y, 8, 1) > 0.21){
floor = Blocks.iron;
}
if(Noise.nnoise(x, y, 6, 1) > 0.237){
floor = Blocks.coal;
}
if(Noise.nnoise(x + 9999, y + 9999, 8, 1) > 0.27){
floor = Blocks.titanium;
}
if(Noise.nnoise(x + 99999, y + 99999, 7, 1) > 0.259){
floor = Blocks.uranium;
}
}
if(color == Hue.rgb(Color.PURPLE)){
if(!Vars.android) new Enemy(EnemyTypes.target).set(x * Vars.tilesize, y * Vars.tilesize).add();
floor = Blocks.stone;
}
tiles[x][y].setBlock(block, 0);
tiles[x][y].setFloor(floor);
}
}
for(int x = 0; x < pixmap.getWidth(); x ++){
for(int y = 0; y < pixmap.getHeight(); y ++) {
tiles[x][y].updateOcclusion();
}
}
if(!hascore){
GameState.set(State.menu);
Vars.ui.showError("[orange]Invalid map:[] this map has no core!");
}
if(!hasenemies){
GameState.set(State.menu);
Vars.ui.showError("[orange]Invalid map:[] this map has no enemy spawnpoints!");
}
}
示例15: insertImage
import com.badlogic.gdx.graphics.Pixmap; //導入方法依賴的package包/類
public boolean insertImage(Asset asset, Pixmap image) {
if (rectangles.containsKey(asset))
throw new RuntimeException("Key \"" + asset.toString() + "\" is already in map");
int borderPixels = padding;
borderPixels <<= 1;
PackRectangle rect = new PackRectangle(0, 0, image.getWidth() + borderPixels, image.getHeight() + borderPixels);
Node node = insert(root, rect);
if (node == null)
return false;
node.name = asset.toString();
rect = new PackRectangle(node.rect);
rect.width -= borderPixels;
rect.height -= borderPixels;
borderPixels >>= 1;
rect.x += borderPixels;
rect.y += borderPixels;
rectangles.put(asset, rect);
pixmap.drawPixmap(image, rect.x, rect.y);
if (duplicateBorder) {
pixmap.drawPixmap(image, rect.x, rect.y - 1, 0, 0, image.getWidth(), 1);
pixmap.drawPixmap(image, rect.x, rect.y + image.getHeight(), 0, image.getHeight() - 1, image.getWidth(), 1);
pixmap.drawPixmap(image, rect.x - 1, rect.y, 0, 0, 1, image.getHeight());
pixmap.drawPixmap(image, rect.x + image.getWidth(), rect.y, image.getWidth() - 1, 0, 1, image.getHeight());
pixmap.drawPixel(rect.x - 1, rect.y - 1, image.getPixel(0, 0));
pixmap.drawPixel(rect.x + image.getWidth(), rect.y - 1, image.getPixel(image.getWidth() - 1, 0));
pixmap.drawPixel(rect.x - 1, rect.y + image.getHeight(), image.getPixel(0, image.getHeight() - 1));
pixmap.drawPixel(rect.x + image.getWidth(), rect.y + image.getHeight(),
image.getPixel(image.getWidth() - 1, image.getHeight() - 1));
// pixmap.drawPixmap(image, rect.x - 1, rect.y, rect.x, rect.y +
// rect.height, 0, 0, 1, image.getHeight(), null);
// pixmap.drawPixmap(image, rect.x + rect.width, rect.y, rect.x +
// rect.width + 1, rect.y + rect.height, image.getWidth() - 1, 0);
// pixmap.drawPixmap(image, rect.x - 1, rect.y - 1, rect.x, rect.y,
// 0, 0);
// pixmap.drawPixmap(image, rect.x + rect.width, rect.y - 1, rect.x
// + rect.width + 1, rect.y, image.getWidth() - 1, 0);
// pixmap.drawPixmap(image, rect.x - 1, rect.y + rect.height,
// rect.x, rect.y + rect.height + 1, 0, image.getHeight() - 1);
// pixmap.drawPixmap(image, rect.x + rect.width, rect.y +
// rect.height, rect.x + rect.width + 1, rect.y + rect.height + 1
// image.getWidth() - 1, image.getHeight() - 1);
}
return true;
}