Examples of Pixmap


Examples of com.badlogic.gdx.graphics.Pixmap

  @Override
  public void consumeCompressedData () {
    if (!isPrepared) throw new GdxRuntimeException("Call prepare() before calling consumeCompressedData()");

    if (Gdx.app.getType() == ApplicationType.Desktop || Gdx.graphics.isGL20Available() == false) {
      Pixmap pixmap = ETC1.decodeImage(data, Format.RGB565);
      Gdx.gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0,
        pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels());
      if (useMipMaps) MipMapGenerator.generateMipMap(pixmap, pixmap.getWidth(), pixmap.getHeight(), false);
      pixmap.dispose();
      useMipMaps = false;
    } else {
      Gdx.gl.glCompressedTexImage2D(GL10.GL_TEXTURE_2D, 0, ETC1.ETC1_RGB8_OES, width, height, 0,
        data.compressedData.capacity() - data.dataOffset, data.compressedData);
      if (useMipMaps()) Gdx.gl20.glGenerateMipmap(GL20.GL_TEXTURE_2D);
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

   * Display explosion animations
   * @param delta Time elapsed
   */
  public void update(float delta){
    if(hasChanged == true) {
      pixmap = new Pixmap(Skitg.WIDTH, Skitg.HEIGHT, Pixmap.Format.RGB888);
     
      //New Texture must be > Pixmap dimensions, and in powers of 2
      texture = new Texture(1024, 1024, Pixmap.Format.RGB888);
      texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Linear);
     
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

      peaks[minB + i] = peaks[minB];
    }
   
   
    //New Pixmap with the width and height of the screen.
    pixmap = new Pixmap(Skitg.WIDTH, Skitg.HEIGHT, Pixmap.Format.RGB888);
   
    //New Texture must be > Pixmap dimensions, and in powers of 2
    texture = new Texture(1024, 1024, Pixmap.Format.RGB888);
    texture.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Linear);
   
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

        continue;
      }
      GlyphSlot slot = face.getGlyph();
      GlyphMetrics metrics = slot.getMetrics();
      Bitmap bitmap = slot.getBitmap();
      Pixmap pixmap = bitmap.getPixmap(Format.RGBA8888);
      Glyph glyph = new Glyph();
      glyph.id = (int)c;
      glyph.width = pixmap.getWidth();
      glyph.height = pixmap.getHeight();
      glyph.xoffset = slot.getBitmapLeft();
      glyph.yoffset = parameter.flip ? -slot.getBitmapTop() + (int)baseLine : -(glyph.height - slot.getBitmapTop())
        - (int)baseLine;
      glyph.xadvance = FreeType.toInt(metrics.getHoriAdvance());

      if (bitmapped) {
        pixmap.setColor(Color.CLEAR);
        pixmap.fill();
        ByteBuffer buf = bitmap.getBuffer();
        for (int h = 0; h < glyph.height; h++) {
          int idx = h * bitmap.getPitch();
          for (int w = 0; w < (glyph.width + glyph.xoffset); w++) {
            int bit = (buf.get(idx + (w / 8)) >>> (7 - (w % 8))) & 1;
            pixmap.drawPixel(w, h, ((bit == 1) ? Color.WHITE.toIntBits() : Color.CLEAR.toIntBits()));
          }
        }

      }

      String name = packPrefix + c;
      Rectangle rect = packer.pack(name, pixmap);

      // determine which page it was packed into
      int pIndex = packer.getPageIndex(name);
      if (pIndex == -1) // we should not get here
        throw new IllegalStateException("packer was not able to insert '" + name + "' into a page");

      glyph.page = pIndex;
      glyph.srcX = (int)rect.x;
      glyph.srcY = (int)rect.y;

      data.setGlyph(c, glyph);
      pixmap.dispose();
    }

    // generate kerning
    for (int i = 0; i < parameter.characters.length(); i++) {
      for (int j = 0; j < parameter.characters.length(); j++) {
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

          + config.fullscreen);

      if (config.iconPaths.size > 0) {
        ByteBuffer[] icons = new ByteBuffer[config.iconPaths.size];
        for (int i = 0, n = config.iconPaths.size; i < n; i++) {
          Pixmap pixmap = new Pixmap(Gdx.files.getFileHandle(config.iconPaths.get(i), config.iconFileTypes.get(i)));
          if (pixmap.getFormat() != Format.RGBA8888) {
            Pixmap rgba = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), Format.RGBA8888);
            rgba.drawPixmap(pixmap, 0, 0);
            pixmap = rgba;
          }
          icons[i] = ByteBuffer.allocateDirect(pixmap.getPixels().limit());
          icons[i].put(pixmap.getPixels()).flip();
          pixmap.dispose();
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

        }
      }
      if (config.iconPaths.size > 0) {
        ByteBuffer[] icons = new ByteBuffer[config.iconPaths.size];
        for (int i = 0, n = config.iconPaths.size; i < n; i++) {
          Pixmap pixmap = new Pixmap(Gdx.files.getFileHandle(config.iconPaths.get(i), config.iconFileTypes.get(i)));
          if (pixmap.getFormat() != Format.RGBA8888) {
            Pixmap rgba = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), Format.RGBA8888);
            rgba.drawPixmap(pixmap, 0, 0);
            pixmap = rgba;
          }
          icons[i] = ByteBuffer.allocateDirect(pixmap.getPixels().limit());
          icons[i].put(pixmap.getPixels()).flip();
          pixmap.dispose();
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

     */
    @Override
    public SpritePack loadSync(AssetManager manager, String fileName, SpritePackParameter parameter) {
        PixmapPacker pixmapPacker = new PixmapPacker(512, 512, Pixmap.Format.RGBA8888, 1, true);
        for(FileHandle file : files) {
            Pixmap pixmap = manager.get(file.path(), Pixmap.class);
            pixmapPacker.pack(file.nameWithoutExtension(), pixmap);
        }
        return new SpritePack(pixmapPacker.generateTextureAtlas(Texture.TextureFilter.Nearest,
                                                                Texture.TextureFilter.Nearest,
                                                                false));
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

        continue;
      }
      GlyphSlot slot = face.getGlyph();
      GlyphMetrics metrics = slot.getMetrics();
      Bitmap bitmap = slot.getBitmap();
      Pixmap pixmap = bitmap.getPixmap(Format.RGBA8888);
      Glyph glyph = new Glyph();
      glyph.id = (int)c;
      glyph.width = pixmap.getWidth();
      glyph.height = pixmap.getHeight();
      glyph.xoffset = slot.getBitmapLeft();
      glyph.yoffset = flip ? -slot.getBitmapTop() + (int)baseLine : -(glyph.height - slot.getBitmapTop()) - (int)baseLine;
      glyph.xadvance = FreeType.toInt(metrics.getHoriAdvance());

      if(bitmapped)
      {
        pixmap.setColor(Color.CLEAR);
        pixmap.fill();
        ByteBuffer buf = bitmap.getBuffer();
        for(int h=0; h<glyph.height; h++)
        {
          int idx = h*bitmap.getPitch();
          for(int w=0; w<(glyph.width+glyph.xoffset); w++)
          {
            int bit = (buf.get(idx+(w/8)) >>> (7-(w%8))) & 1;
            pixmap.drawPixel(w, h, ((bit==1)? Color.WHITE.toIntBits() : Color.CLEAR.toIntBits()));
          }
        }
       
      }

      String name = packPrefix + c;
      Rectangle rect = packer.pack(name, pixmap);
     
      //determine which page it was packed into
      int pIndex = packer.getPageIndex(name);
      if (pIndex==-1) //we should not get here
        throw new IllegalStateException("packer was not able to insert '"+name+"' into a page");
     
      glyph.page = pIndex;
      glyph.srcX = (int)rect.x;
      glyph.srcY = (int)rect.y;
     
      data.setGlyph(c, glyph);
      pixmap.dispose();
    }

    // generate kerning
    for (int i = 0; i < characters.length(); i++) {
      for (int j = 0; j < characters.length(); j++) {
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

    debugRenderer = new SkeletonRendererDebug();

    final String name = "goblins"; // "spineboy";

    // A regular texture atlas would normally usually be used. This returns a white image for images not found in the atlas.
    Pixmap pixmap = new Pixmap(32, 32, Format.RGBA8888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    final AtlasRegion fake = new AtlasRegion(new Texture(pixmap), 0, 0, 32, 32);
    pixmap.dispose();
    FileHandle atlasFile = Gdx.files.internal(name + ".atlas");
    TextureAtlasData data = !atlasFile.exists() ? null : new TextureAtlasData(atlasFile, atlasFile.parent(), false);
    TextureAtlas atlas = new TextureAtlas(data) {
      public AtlasRegion findRegion (String name) {
        AtlasRegion region = super.findRegion(name);
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

        continue;
      }
      GlyphSlot slot = face.getGlyph();
      GlyphMetrics metrics = slot.getMetrics();
      Bitmap bitmap = slot.getBitmap();
      Pixmap pixmap = bitmap.getPixmap(Format.RGBA8888);
      Glyph glyph = new Glyph();
      glyph.id = (int)c;
      glyph.width = pixmap.getWidth();
      glyph.height = pixmap.getHeight();
      glyph.xoffset = slot.getBitmapLeft();
      glyph.yoffset = parameter.flip ? -slot.getBitmapTop() + (int)baseLine : -(glyph.height - slot.getBitmapTop())
        - (int)baseLine;
      glyph.xadvance = FreeType.toInt(metrics.getHoriAdvance());

      if (bitmapped) {
        pixmap.setColor(Color.CLEAR);
        pixmap.fill();
        ByteBuffer buf = bitmap.getBuffer();
        for (int h = 0; h < glyph.height; h++) {
          int idx = h * bitmap.getPitch();
          for (int w = 0; w < (glyph.width + glyph.xoffset); w++) {
            int bit = (buf.get(idx + (w / 8)) >>> (7 - (w % 8))) & 1;
            pixmap.drawPixel(w, h, ((bit == 1) ? Color.WHITE.toIntBits() : Color.CLEAR.toIntBits()));
          }
        }

      }

      String name = packPrefix + c;
      Rectangle rect = packer.pack(name, pixmap);

      // determine which page it was packed into
      int pIndex = packer.getPageIndex(name);
      if (pIndex == -1) // we should not get here
        throw new IllegalStateException("packer was not able to insert '" + name + "' into a page");

      glyph.page = pIndex;
      glyph.srcX = (int)rect.x;
      glyph.srcY = (int)rect.y;

      data.setGlyph(c, glyph);
      pixmap.dispose();
    }

    // generate kerning
    for (int i = 0; i < parameter.characters.length(); i++) {
      for (int j = 0; j < parameter.characters.length(); j++) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.