@Override protected CompletableFuture<Texture> loadDisposable() { InputStream textureStream = null; try { // load the spritesheet here textureStream = sourceFile.getInputStream(sourceFile.getEntry(ENTRY_SPRITESHEET)); Gdx2DPixmap readMap = new Gdx2DPixmap(textureStream, Gdx2DPixmap.GDX2D_FORMAT_RGBA8888); Texture texture = new Texture(new Pixmap(readMap)); readMap.dispose(); this.loadSheet(texture); return CompletableFuture.completedFuture(texture); } catch (Exception e) { log.error("Failed to load packaged spritesheet", e); } finally { StreamUtil.closeQuietly(textureStream); } return null; }
@Override public void onDisplay(DirectMediaPlayer mediaPlayer, int[] data) { if (size != data.length) { byteBuffer = ByteBuffer.allocateDirect(data.length * 4).order(ByteOrder.nativeOrder()); size = data.length; } IntBuffer intBuffer = byteBuffer.asIntBuffer(); intBuffer.put(data); try { Gdx2DPixmap pixmapData = new Gdx2DPixmap(byteBuffer, nativeData); pixmap = new Pixmap(pixmapData); // System.out.println("movie pixmap created : " + mediaPlayer.getTime() + " / " + mediaPlayer.getLength() // + " data size : " + data.length * 4); } catch (Exception e) { pixmap = null; throw new GdxRuntimeException("Couldn't load pixmap from image data", e); } }
public static Texture loadTexture(Crypto crypto, FileHandle file, Pixmap.Format format, boolean useMipMaps) { try { byte[] bytes = file.readBytes(); if (crypto != null) { bytes = crypto.decrypt(bytes, true); } Pixmap pixmap = new Pixmap(new Gdx2DPixmap(bytes, 0, bytes.length, 0)); return new Texture(pixmap, format, useMipMaps); } catch (Exception e) { throw new GdxRuntimeException("Couldn't load file: " + file, e); } }
public static int toGdx2DPixmapFormat (Format format) { if (format == Alpha) return Gdx2DPixmap.GDX2D_FORMAT_ALPHA; if (format == Intensity) return Gdx2DPixmap.GDX2D_FORMAT_ALPHA; if (format == LuminanceAlpha) return Gdx2DPixmap.GDX2D_FORMAT_LUMINANCE_ALPHA; if (format == RGB565) return Gdx2DPixmap.GDX2D_FORMAT_RGB565; if (format == RGBA4444) return Gdx2DPixmap.GDX2D_FORMAT_RGBA4444; if (format == RGB888) return Gdx2DPixmap.GDX2D_FORMAT_RGB888; if (format == RGBA8888) return Gdx2DPixmap.GDX2D_FORMAT_RGBA8888; throw new GdxRuntimeException("Unknown Format: " + format); }
public static Format fromGdx2DPixmapFormat (int format) { if (format == Gdx2DPixmap.GDX2D_FORMAT_ALPHA) return Alpha; if (format == Gdx2DPixmap.GDX2D_FORMAT_LUMINANCE_ALPHA) return LuminanceAlpha; if (format == Gdx2DPixmap.GDX2D_FORMAT_RGB565) return RGB565; if (format == Gdx2DPixmap.GDX2D_FORMAT_RGBA4444) return RGBA4444; if (format == Gdx2DPixmap.GDX2D_FORMAT_RGB888) return RGB888; if (format == Gdx2DPixmap.GDX2D_FORMAT_RGBA8888) return RGBA8888; throw new GdxRuntimeException("Unknown Gdx2DPixmap Format: " + format); }
/** Creates a new Pixmap instance from the given encoded image data. The image can be encoded as JPEG, PNG or BMP. * @param encodedData the encoded image data * @param offset the offset * @param len the length */ public Pixmap (byte[] encodedData, int offset, int len) { try { pixmap = new Gdx2DPixmap(encodedData, offset, len, 0); } catch (IOException e) { throw new GdxRuntimeException("Couldn't load pixmap from image data", e); } }
/** Creates a new Pixmap instance from the given file. The file must be a Png, Jpeg or Bitmap. Paletted formats are not * supported. * * @param file the {@link FileHandle} */ public Pixmap (FileHandle file) { try { byte[] bytes = file.readBytes(); pixmap = new Gdx2DPixmap(bytes, 0, bytes.length, 0); } catch (Exception e) { throw new GdxRuntimeException("Couldn't load file: " + file, e); } }
Texture textureFromPixmap (Gdx2DPixmap pixmap) { Texture texture = new Texture(pixmap.getWidth(), pixmap.getHeight(), Format.RGB565); texture.bind(); Gdx.gl.glTexImage2D(GL20.GL_TEXTURE_2D, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); return texture; }
Gdx2DPixmap[] testPixmaps () { int[] formats = {Gdx2DPixmap.GDX2D_FORMAT_ALPHA, Gdx2DPixmap.GDX2D_FORMAT_LUMINANCE_ALPHA, Gdx2DPixmap.GDX2D_FORMAT_RGB565, Gdx2DPixmap.GDX2D_FORMAT_RGB888, Gdx2DPixmap.GDX2D_FORMAT_RGBA4444, Gdx2DPixmap.GDX2D_FORMAT_RGBA8888}; Gdx2DPixmap[] pixmaps = new Gdx2DPixmap[formats.length]; for (int i = 0; i < pixmaps.length; i++) { Gdx2DPixmap pixmap = new Gdx2DPixmap(64, 32, formats[i]); drawToPixmap(pixmap); pixmaps[i] = pixmap; } return pixmaps; }
public Pixmap(FileHandle paramFileHandle) { try { byte[] arrayOfByte = paramFileHandle.readBytes(); this.pixmap = new Gdx2DPixmap(arrayOfByte, 0, arrayOfByte.length, 0); return; } catch (Exception localException) { throw new GdxRuntimeException("Couldn't load file: " + paramFileHandle, localException); } }
public Pixmap(byte[] paramArrayOfByte, int paramInt1, int paramInt2) { try { this.pixmap = new Gdx2DPixmap(paramArrayOfByte, paramInt1, paramInt2, 0); return; } catch (IOException localIOException) { throw new GdxRuntimeException("Couldn't load pixmap from image data", localIOException); } }
public static void setBlending(Pixmap.Blending paramBlending) { blending = paramBlending; if (paramBlending == Pixmap.Blending.None); for (int i = 0; ; i = 1) { Gdx2DPixmap.setBlend(i); return; } }
public static void setFilter(Pixmap.Filter paramFilter) { if (paramFilter == Pixmap.Filter.NearestNeighbour); for (int i = 0; ; i = 1) { Gdx2DPixmap.setScale(i); return; } }
/** * Allocates a new {@link Pixmap} without zeroing its memory like the regular constructor * ({@link Pixmap#Pixmap(int, int, Format)}) */ public static Pixmap newUninitializedPixmap(int width, int height, Format format) { Gdx2DPixmap gdx2dPixmap = new Gdx2DPixmap(width, height, Format.toGdx2DPixmapFormat(format)); return new Pixmap(gdx2dPixmap); }
/** Sets the type of {@link Blending} to be used for all operations. Default is {@link Blending#SourceOver}. * @param blending the blending type */ public static void setBlending (Blending blending) { Pixmap.blending = blending; Gdx2DPixmap.setBlend(blending == Blending.None ? 0 : 1); }
/** Sets the type of interpolation {@link Filter} to be used in conjunction with * {@link Pixmap#drawPixmap(Pixmap, int, int, int, int, int, int, int, int)}. * @param filter the filter. */ public static void setFilter (Filter filter) { Gdx2DPixmap.setScale(filter == Filter.NearestNeighbour ? Gdx2DPixmap.GDX2D_SCALE_NEAREST : Gdx2DPixmap.GDX2D_SCALE_LINEAR); }
/** Creates a new Pixmap instance with the given width, height and format. * @param width the width in pixels * @param height the height in pixels * @param format the {@link Format} */ public Pixmap (int width, int height, Format format) { pixmap = new Gdx2DPixmap(width, height, Format.toGdx2DPixmapFormat(format)); setColor(0, 0, 0, 0); fill(); }
/** Constructs a new Pixmap from a {@link Gdx2DPixmap}. * @param pixmap */ public Pixmap (Gdx2DPixmap pixmap) { this.pixmap = pixmap; }
void drawToPixmap (Gdx2DPixmap pixmap) { pixmap.clear(Color.rgba8888(1, 0, 0, 0.1f)); pixmap.setPixel(16, 16, Color.rgba8888(0, 0, 1, 1)); int clearColor = 0; int pixelColor = 0; switch (pixmap.getFormat()) { case Gdx2DPixmap.GDX2D_FORMAT_ALPHA: clearColor = Color.rgba8888(1, 1, 1, 0.1f); pixelColor = Color.rgba8888(1, 1, 1, 1); break; case Gdx2DPixmap.GDX2D_FORMAT_LUMINANCE_ALPHA: clearColor = 0x36363619; // Color.rgba8888(1, 1, 1, 0.1f); pixelColor = 0xffffff12; break; case Gdx2DPixmap.GDX2D_FORMAT_RGB565: clearColor = Color.rgba8888(1, 0, 0, 1); pixelColor = Color.rgba8888(0, 0, 1, 1); break; case Gdx2DPixmap.GDX2D_FORMAT_RGB888: clearColor = Color.rgba8888(1, 0, 0, 1); pixelColor = Color.rgba8888(0, 0, 1, 1); break; case Gdx2DPixmap.GDX2D_FORMAT_RGBA4444: clearColor = 0xff000011; pixelColor = Color.rgba8888(0, 0, 1, 1); break; case Gdx2DPixmap.GDX2D_FORMAT_RGBA8888: clearColor = Color.rgba8888(1, 0, 0, 0.1f); pixelColor = Color.rgba8888(0, 0, 1, 1); } if (pixmap.getPixel(15, 16) != clearColor) throw new RuntimeException("error clear: " + pixmap.getFormatString()); if (pixmap.getPixel(16, 16) != pixelColor) throw new RuntimeException("error pixel: " + pixmap.getFormatString()); pixmap.drawLine(0, 0, 31, 31, Color.rgba8888(1, 1, 1, 1)); pixmap.drawRect(10, 10, 5, 7, Color.rgba8888(1, 1, 0, 0.5f)); pixmap.fillRect(20, 10, 5, 7, Color.rgba8888(0, 1, 1, 0.5f)); pixmap.drawCircle(16, 16, 10, Color.rgba8888(1, 0, 1, 1)); pixmap.fillCircle(16, 16, 6, Color.rgba8888(0, 1, 0, 0.5f)); pixmap.fillTriangle(16, 16, 18, 18, 20, 14, Color.rgba8888(0, 0.5f, 0, 0.5f)); pixmap.drawLine(0, -1, 0, 0, Color.rgba8888(1, 1, 0, 1)); pixmap.drawLine(41, -10, 31, 0, Color.rgba8888(1, 1, 0, 1)); pixmap.drawLine(10, 41, 0, 31, Color.rgba8888(0, 1, 1, 1)); pixmap.drawLine(41, 41, 31, 31, Color.rgba8888(0, 1, 1, 1)); pixmap.drawRect(-10, -10, 20, 20, Color.rgba8888(0, 1, 1, 1)); pixmap.drawRect(21, -10, 20, 20, Color.rgba8888(0, 1, 1, 1)); pixmap.drawRect(-10, 21, 20, 20, Color.rgba8888(0, 1, 1, 1)); pixmap.drawRect(21, 21, 20, 20, Color.rgba8888(0, 1, 1, 1)); pixmap.fillRect(-10, -10, 20, 20, Color.rgba8888(0, 1, 1, 0.5f)); pixmap.fillRect(21, -10, 20, 20, Color.rgba8888(0, 1, 1, 0.5f)); pixmap.fillRect(-10, 21, 20, 20, Color.rgba8888(0, 1, 1, 0.5f)); pixmap.fillRect(21, 21, 20, 20, Color.rgba8888(0, 1, 1, 0.5f)); }
public IosBitmap(InputStream inputStream) throws IOException { pixmap = new Pixmap(new Gdx2DPixmap(inputStream, Gdx2DPixmap.GDX2D_FORMAT_RGBA8888)); }
public Pixmap(int paramInt1, int paramInt2, Pixmap.Format paramFormat) { this.pixmap = new Gdx2DPixmap(paramInt1, paramInt2, Pixmap.Format.toGdx2DPixmapFormat(paramFormat)); setColor(0.0F, 0.0F, 0.0F, 0.0F); fill(); }
public Pixmap(Gdx2DPixmap paramGdx2DPixmap) { this.pixmap = paramGdx2DPixmap; }