Package net.sourceforge.dsnk.model

Examples of net.sourceforge.dsnk.model.Texture


   * @return texture or null if given index has length -1
   * @throws IOException
   *             if an io error occurs
   */
  public Texture read(TexIdx idx) throws IOException {
    Texture texture = new Texture(idx);

    if (idx.getLength() == -1) {
      return null;
    }

    int width = 0;
    int height = 0;
    switch (idx.getLength()) {
    case -1:
      return null;

    case TexIdx.SMALL_TEXTURE:
      width = 64;
      height = 64;
      break;

    case TexIdx.BIG_TEXTURE:
      width = 128;
      height = 128;
      break;

    default:
      return null;
    }

    BufferedImage image = new BufferedImage(width, height,
        BufferedImage.TYPE_INT_ARGB);
    WritableRaster wr = image.getRaster();

    // get texture data for index
    byte[] texData = new byte[idx.getLength()];
    System.arraycopy(data, idx.getStart(), texData, 0, idx.getLength());

    // draw data to image
    drawData(wr, texData, width, height);
    texture.setImage(image);

    return texture;
  }
View Full Code Here


              LandTile tile = this.tileGroups[tileGroupIdx].getTiles()[tileIdx];
             
              TexIdx textureIndex = this.texIdxs[(int)tile.getTextureId()];
             
              try {
                Texture texture = this.textureReader.read(textureIndex);
               
                // draw blocks from top to bottom and the left to
                // right
                // draw cells from left to right and then from top
                // to bottom
                if (texture != null) {
                  g.drawImage(texture.getImage(), (i * 512) + (m * 64) + 10, (j * 512) + (k * 64) + 30, null);
                }
              } catch (IOException e) {
                e.printStackTrace();
              }
            }
View Full Code Here

    // fetch the land tile
    LandTile tile = this.tileGroups[tileGroupIdx].getTiles()[tileIdx];
    TexIdx textureIndex = this.texIdxs[(int) tile.getTextureId()];

    // fetch the texture object
    Texture texture = null;
    try {
      texture = this.textureCache.get(textureIndex.getStart());
    } catch (CacheItemNotFoundException e) {
      // not found in cache, so load
      texture = textureReader.read(textureIndex);
      // put texture into cache
      this.textureCache.put(textureIndex.getStart(), texture);
    }

    // and the image of the texture
    Image textureImg = null;
    if (texture != null) {
      textureImg = texture.getImage();
    } else {
      // create dummy image
      textureImg = graphicsConfiguration.createCompatibleImage(64, 64,
          Transparency.TRANSLUCENT);
      Graphics g = textureImg.getGraphics();
View Full Code Here

TOP

Related Classes of net.sourceforge.dsnk.model.Texture

Copyright © 2018 www.massapicom. 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.