Examples of Pixmap


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
    if (parameter.kerning) {
      for (int i = 0; i < parameter.characters.length(); i++) {
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

   
    /**
     * @return Pixmap representing the glyph, needs to be disposed manually.
     */
    public Pixmap getPixmap(Format format) {
      Pixmap pixmap = new Pixmap(getWidth(), getRows(), Format.Alpha);
      BufferUtils.copy(getBuffer(), pixmap.getPixels(), pixmap.getPixels().capacity());
      Pixmap converted = new Pixmap(pixmap.getWidth(), pixmap.getHeight(), format);
      Blending blending = Pixmap.getBlending();
      Pixmap.setBlending(Blending.None);
      converted.drawPixmap(pixmap, 0, 0);
      Pixmap.setBlending(blending);
      pixmap.dispose();
      return converted;
    }
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

    return rect;
  }

  private void newPage () {
    Page page = new Page();
    page.image = new Pixmap(pageWidth, pageHeight, pageFormat);
    page.root = new Node(0, 0, pageWidth, pageHeight, null, null, null);
    page.rects = new OrderedMap<String, Rectangle>();
    pages.add(page);
    currPage = page;
  }
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

  @Override
  public void loadAsync (AssetManager manager, String fileName, FileHandle file, TextureParameter parameter) {
    info.filename = fileName;
    if (parameter == null || parameter.textureData == null) {
      Pixmap pixmap = null;
      Format format = null;
      boolean genMipMaps = false;
      info.texture = null;

      if (parameter != null) {
        format = parameter.format;
        genMipMaps = parameter.genMipMaps;
        info.texture = parameter.texture;
      }

      if (!fileName.contains(".etc1")) {
        if (fileName.contains(".cim"))
          pixmap = PixmapIO.readCIM(file);
        else
          pixmap = new Pixmap(file);
        info.data = new FileTextureData(file, pixmap, format, genMipMaps);
      } else {
        info.data = new ETC1TextureData(file, genMipMaps);
      }
    } else {
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

  }

  @Override
  public void loadAsync (AssetManager manager, String fileName, FileHandle fileHandle, TextureParameter parameter) {
    if (parameter == null || (parameter != null && parameter.textureData == null)) {
      Pixmap pixmap = null;
      Format format = null;
      boolean genMipMaps = false;
      texture = null;

      if (parameter != null) {
        format = parameter.format;
        genMipMaps = parameter.genMipMaps;
        texture = parameter.texture;
      }

      FileHandle handle = resolve(fileName);
      pixmap = new Pixmap(handle);
      data = new FileTextureData(handle, pixmap, format, genMipMaps);
    } else {
      data = parameter.textureData;
      if (!data.isPrepared()) data.prepare();
      texture = parameter.texture;
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

  @Override
  public void prepare () {
    if (isPrepared) throw new GdxRuntimeException("Already prepared");
    if (pixmap == null) {
      pixmap = ensurePot(new Pixmap(file));
      width = pixmap.getWidth();
      height = pixmap.getHeight();
      if (format == null) format = pixmap.getFormat();
    }
    isPrepared = true;
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

      int pixmapWidth = pixmap.getWidth();
      int pixmapHeight = pixmap.getHeight();
      int potWidth = MathUtils.nextPowerOfTwo(pixmapWidth);
      int potHeight = MathUtils.nextPowerOfTwo(pixmapHeight);
      if (pixmapWidth != potWidth || pixmapHeight != potHeight) {
        Pixmap tmp = new Pixmap(potWidth, potHeight, pixmap.getFormat());
        tmp.drawPixmap(pixmap, 0, 0, 0, 0, pixmapWidth, pixmapHeight);
        pixmap.dispose();
        return tmp;
      }
    }
    return pixmap;
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

  @Override
  public Pixmap consumePixmap () {
    if (!isPrepared) throw new GdxRuntimeException("Call prepare() before calling getPixmap()");
    isPrepared = false;
    Pixmap pixmap = this.pixmap;
    this.pixmap = null;
    return pixmap;
  }
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

  @Override
  public void prepare () {
    if (isPrepared) throw new GdxRuntimeException("Already prepared");
    if (pixmap == null) {
      pixmap = ensurePot(new Pixmap(file));
      width = pixmap.getWidth();
      height = pixmap.getHeight();
      if (format == null) format = pixmap.getFormat();
    }
    isPrepared = true;
View Full Code Here

Examples of com.badlogic.gdx.graphics.Pixmap

      int pixmapWidth = pixmap.getWidth();
      int pixmapHeight = pixmap.getHeight();
      int potWidth = MathUtils.nextPowerOfTwo(pixmapWidth);
      int potHeight = MathUtils.nextPowerOfTwo(pixmapHeight);
      if (pixmapWidth != potWidth || pixmapHeight != potHeight) {
        Pixmap tmp = new Pixmap(potWidth, potHeight, pixmap.getFormat());
        tmp.drawPixmap(pixmap, 0, 0, 0, 0, pixmapWidth, pixmapHeight);
        pixmap.dispose();
        return tmp;
      }
    }
    return pixmap;
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.