List of usage examples for com.badlogic.gdx.graphics Pixmap Pixmap
public Pixmap(byte[] encodedData, int offset, int len)
From source file:org.bladecoder.bladeengine.util.RectangleRenderer.java
License:Apache License
private static Texture makePixel() { Texture _temp;//from www .j a v a 2 s. com Pixmap p = new Pixmap(1, 1, Pixmap.Format.RGBA8888); p.setColor(new Color(1, 1, 1, 1)); p.fillRectangle(0, 0, 1, 1); _temp = new Texture(p, true); p.dispose(); return _temp; }
From source file:org.catrobat.catroid.common.DroneVideoLookData.java
License:Open Source License
@Override public Pixmap getPixmap() { // BUG: Height() should be 1280, but it is 1184, so we need an scaling factor of 1.081081 int virtualScreenHeight = (int) Math.round(1.081081 * ScreenValues.SCREEN_HEIGHT); defaultVideoTextureSize = new int[] { virtualScreenHeight, ScreenValues.SCREEN_WIDTH }; if (pixmap == null) { pixmap = new Pixmap(virtualScreenHeight, ScreenValues.SCREEN_WIDTH, Pixmap.Format.RGB888); pixmap.setColor(Color.BLUE); pixmap.fill();/*from w w w .ja v a 2 s . c om*/ pixmap.setBlending(Pixmap.Blending.None); } return pixmap; }
From source file:org.catrobat.catroid.stage.Passepartout.java
License:Open Source License
Passepartout(int screenWidth, int screenHeight, int screenViewPortWidth, int screenViewPortHeight, float virtualScreenWidth, float virtualScreenHeight) { this.virtualScreenWidth = virtualScreenWidth; this.virtualScreenHeight = virtualScreenHeight; passepartoutHeight = ((screenHeight / (screenViewPortHeight / virtualScreenHeight)) - virtualScreenHeight) / 2f;/*from www .j a v a2 s. c om*/ passepartoutWidth = ((screenWidth / (screenViewPortWidth / virtualScreenWidth)) - virtualScreenWidth) / 2f; Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888); pixmap.setColor(passepartoutColor); pixmap.fill(); texture = new Texture(pixmap); }
From source file:org.catrobat.catroid.stage.ShowBubbleActor.java
License:Open Source License
private Pixmap getFinalBubble(int width, int height, Bitmap bitmap, boolean right) { Paint paint = new Paint(); paint.setColor(android.graphics.Color.BLACK); paint.setStyle(Paint.Style.FILL_AND_STROKE); paint.setStrokeWidth(2);//w w w .java 2 s . co m Bitmap tempBitmap = Bitmap.createBitmap(width, height + Constants.OFFSET_FOR_THINK_BUBBLES_AND_ARROW, Bitmap.Config.ARGB_8888); Canvas tempCanvas = new Canvas(tempBitmap); tempCanvas.drawBitmap(bitmap, 0, 0, null); if (type == Constants.SAY_BRICK) { tempCanvas.drawPath(getSayTrianglePath(tempBitmap.getHeight(), tempBitmap.getWidth(), right), paint); paint.setColor(android.graphics.Color.WHITE); tempCanvas.drawPath(getSayTrianglePathSmaller(tempBitmap.getHeight(), tempBitmap.getWidth(), right), paint); } else { Bitmap thinkBubbles = getThinkBubbles(right); int startPos = right ? 0 : tempBitmap.getWidth() - 2 * Constants.OFFSET_FOR_THINK_BUBBLES_AND_ARROW; tempCanvas.drawBitmap(thinkBubbles, startPos, bitmap.getHeight(), null); } ByteArrayOutputStream stream = new ByteArrayOutputStream(); tempBitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); byte[] bytes = stream.toByteArray(); return new Pixmap(bytes, 0, bytes.length); }
From source file:org.ege.utils.ScreenUtils.java
License:Apache License
/** Returns a portion of the default framebuffer contents specified by x, y, width and height as a {@link TextureRegion} with * the same dimensions. The base {@link Texture} always has {@link MathUtils#nextPowerOfTwo} dimensions and RGBA8888 * {@link Format}. It can be accessed via {@link TextureRegion#getTexture}. This texture is not managed and has to be reloaded * manually on a context loss. If the width and height specified are larger than the framebuffer dimensions, the Texture will * be padded accordingly. Pixels that fall outside of the current screen will have RGBA values of 0. * /*from w w w .java2s. c o m*/ * @param x the x position of the framebuffer contents to capture * @param y the y position of the framebuffer contents to capture * @param w the width of the framebuffer contents to capture * @param h the height of the framebuffer contents to capture */ public static TextureRegion getFrameBufferTexture(int x, int y, int w, int h) { Gdx.gl.glPixelStorei(GL10.GL_PACK_ALIGNMENT, 1); final int potW = MathUtils.nextPowerOfTwo(w); final int potH = MathUtils.nextPowerOfTwo(h); final Pixmap pixmap = new Pixmap(potW, potH, Format.RGBA8888); ByteBuffer pixels = pixmap.getPixels(); Gdx.gl.glReadPixels(x, y, potW, potH, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE, pixels); Texture texture = new Texture(pixmap); TextureRegion textureRegion = new TextureRegion(texture, 0, h, w, -h); pixmap.dispose(); return textureRegion; }
From source file:org.illarion.engine.backend.gdx.GdxWorldMap.java
License:Open Source License
GdxWorldMap(@Nonnull final WorldMapDataProvider provider) { this.provider = provider; mapOrigin = new Location(); playerLocation = new Location(); worldMapPixels = new Pixmap(WORLD_MAP_WIDTH, WORLD_MAP_HEIGHT, Pixmap.Format.RGB888); worldMapTexture = new GdxTexture(new TextureRegion(new Texture(worldMapPixels))); tempDrawingColor = new Color(); }
From source file:org.lightjason.examples.pokemon.simulation.environment.CEnvironment.java
License:LGPL
@Override public final TiledMap map() { // create background checkerboard with a tile map final Pixmap l_pixmap = new Pixmap(2 * m_cellsize, m_cellsize, Pixmap.Format.RGBA8888); l_pixmap.setColor(new Color(0.8f, 0.1f, 0.1f, 0.5f)); l_pixmap.fillRectangle(0, 0, m_cellsize, m_cellsize); l_pixmap.setColor(new Color(0.5f, 0.5f, 0.5f, 0.5f)); l_pixmap.fillRectangle(m_cellsize, 0, m_cellsize, m_cellsize); final Texture l_texture = new Texture(l_pixmap); final TiledMapTile l_region1 = new StaticTiledMapTile( new TextureRegion(l_texture, 0, 0, m_cellsize, m_cellsize)); final TiledMapTile l_region2 = new StaticTiledMapTile( new TextureRegion(l_texture, m_cellsize, 0, m_cellsize, m_cellsize)); // create tilemap final TiledMap l_map = new TiledMap(); final TiledMapTileLayer l_layer = new TiledMapTileLayer(m_column, m_row, m_cellsize, m_cellsize); l_map.getLayers().add(l_layer);// w w w .j ava 2s .c o m IntStream.range(0, m_column).forEach(x -> { IntStream.range(0, m_row).forEach(y -> { final TiledMapTileLayer.Cell l_cell = new TiledMapTileLayer.Cell(); l_layer.setCell(x, y, l_cell); l_cell.setTile( y % 2 != 0 ? x % 2 != 0 ? l_region1 : l_region2 : x % 2 != 0 ? l_region2 : l_region1); }); }); return l_map; }
From source file:org.lightjason.examples.pokemon.simulation.item.IBaseItem.java
License:LGPL
@Override public final void spriteinitialize(final int p_rows, final int p_columns, final int p_cellsize, final float p_unit) { // variables are defined as size1 = x-size & size2 = y-size final float l_size1 = p_cellsize * (int) m_position.getQuick(3); final float l_size2 = p_cellsize * (int) m_position.getQuick(2); // create a colored block of the item final Pixmap l_pixmap = new Pixmap(p_cellsize, p_cellsize, Pixmap.Format.RGBA8888); l_pixmap.setColor(m_color);// w ww . ja v a2 s .c o m l_pixmap.fillRectangle(0, 0, (int) l_size2, (int) l_size1); // add the square to a sprite (for visualization) and use 100% of cell size m_sprite = new Sprite(new Texture(l_pixmap), 0, 0, (int) l_size2, (int) l_size1); m_sprite.setSize(l_size1, l_size2); m_sprite.setOrigin(1.5f / p_cellsize, 1.5f / p_cellsize); m_sprite.setPosition((float) m_position.get(1), (float) m_position.get(0)); m_sprite.setScale(p_unit); }
From source file:org.lightjason.examples.pokemon.ui.CScreen.java
License:LGPL
/** * takes a screenshot//ww w. jav a 2s . c o m * * @return self reference */ private CScreen screenshot() { if (!m_screenshottake) return this; m_screenshottake = false; final byte[] l_pixels = ScreenUtils.getFrameBufferPixels(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight(), true); final Pixmap l_pixmap = new Pixmap(Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight(), Pixmap.Format.RGBA8888); BufferUtils.copy(l_pixels, 0, l_pixmap.getPixels(), l_pixels.length); PixmapIO.writePNG(new FileHandle( MessageFormat.format(m_screenshot.getLeft(), String.format(m_screenshot.getMiddle(), m_iteration)) + ".png"), l_pixmap); l_pixmap.dispose(); return this; }
From source file:org.oscim.gdx.client.GwtBitmap.java
License:Open Source License
/** always argb8888 */ public GwtBitmap(int width, int height, int format) { pixmap = new Pixmap(width, height, null); }