List of usage examples for com.badlogic.gdx.graphics Pixmap Pixmap
public Pixmap(byte[] encodedData, int offset, int len)
From source file:se.angergard.game.util.TextureUtils.java
License:Apache License
public static final Texture createTexture(Color color, int width, int height) { Pixmap pixmap = new Pixmap(width, height, Format.RGBA8888); pixmap.setColor(color);/*from w w w . j a v a2 s . c om*/ pixmap.fill(); Texture texture = new Texture(pixmap); pixmap.dispose(); return texture; }
From source file:se.angergard.game.util.Util.java
License:Apache License
public static final Texture createSolidCircleTexture(Color color, int width, int height) { Pixmap map = new Pixmap(width, height, Format.RGBA8888); Color alpha = new Color(0, 0, 0, 0); map.setColor(alpha);/*from ww w . j a v a 2s . c o m*/ map.fill(); map.setColor(color); map.fillCircle(width / 2, height / 2, ((width + height) / 2) / 2); Texture texture = new Texture(map); map.dispose(); return texture; }
From source file:se.angergard.game.util.Util.java
License:Apache License
public static final Texture createSolidTexture(Color color, int width, int height) { Pixmap map = new Pixmap(width, height, Format.RGB888); map.setColor(color);/* w w w . j a va2 s. co m*/ map.fill(); Texture texture = new Texture(map); map.dispose(); return texture; }
From source file:seventh.client.gfx.Art.java
License:Open Source License
/** * Loads a pixel map from the file system. * // ww w .jav a 2 s. c o m * @param image * @return the Pixmap */ public static Pixmap loadPixmap(String image) { try { return TextureUtil.loadPixmap(image); } catch (Exception e) { Cons.println("*** A problem occured loading an image: " + e); } return new Pixmap(10, 10, Format.RGBA8888); }
From source file:seventh.client.gfx.TextureUtil.java
License:Open Source License
public static Pixmap subPixmap(Pixmap pix, int x, int y, int width, int height) { Pixmap sub = new Pixmap(width, height, pix.getFormat()); sub.drawPixmap(pix, x, y, width, height, 0, 0, width, height); return sub;/*from ww w.j a va2 s .co m*/ }
From source file:seventh.client.gfx.TextureUtil.java
License:Open Source License
/** * Applying mask into image using specified masking color. Any Color in the * image that matches the masking color will be converted to transparent. * // w w w . ja v a 2 s. com * @param img The source image * @param keyColor Masking color * @return Masked image */ public static Pixmap applyMask(Pixmap img, Color keyColor) { Pixmap alpha = new Pixmap(img.getWidth(), img.getHeight(), Format.RGBA8888); //alpha.drawPixmap(img, 0, 0); int width = alpha.getWidth(); int height = alpha.getHeight(); int colorMask = Color.rgba8888(keyColor); //alpha.setColor(0xff00009f); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int col = img.getPixel(x, y); if (col != colorMask) { alpha.drawPixel(x, y, img.getPixel(x, y)); } } } return alpha; }
From source file:seventh.client.gfx.TextureUtil.java
License:Open Source License
public static Pixmap toWhite(Pixmap img) { Pixmap alpha = new Pixmap(img.getWidth(), img.getHeight(), Format.RGBA8888); //alpha.drawPixmap(img, 0, 0); int width = alpha.getWidth(); int height = alpha.getHeight(); //alpha.setColor(0xff00009f); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int col = img.getPixel(x, y); Color color = new Color(col); if (color.a > 0.2f) { alpha.drawPixel(x, y, Color.WHITE.toIntBits()); }//from w w w.j a v a2 s .c o m } } img.dispose(); return alpha; }
From source file:seventh.client.gfx.TextureUtil.java
License:Open Source License
/** * Resizes the image/* www . j a v a 2s. com*/ * * @param image * @param width * @param height * @return */ public static Pixmap resizePixmap(Pixmap image, int width, int height) { Pixmap pix = new Pixmap(width, height, image.getFormat()); pix.drawPixmap(image, 0, 0, width, height, // destination 0, 0, image.getWidth(), image.getHeight()); // source return pix; }
From source file:seventh.client.gfx.TextureUtil.java
License:Open Source License
public static Pixmap createPixmap(int width, int height) { return new Pixmap(width, height, Format.RGBA8888); }
From source file:seventh.client.gfx.TextureUtil.java
License:Open Source License
/** * Splits the image /*from w ww . j ava 2 s . com*/ * @param image * @param width * @param height * @param row * @param col * @return */ public static Pixmap[] splitPixmap(Pixmap image, int width, int height, int row, int col) { int total = col * row; // total returned images int frame = 0; // frame counter int w = width / col; int h = height / row; Pixmap[] images = new Pixmap[total]; for (int j = 0; j < row; j++) { for (int i = 0; i < col; i++) { Pixmap region = new Pixmap(w, h, image.getFormat()); region.drawPixmap(image, 0, 0, i * w, j * h, w, h); images[frame++] = region; } } return images; }