Package org.newdawn.slick.opengl

Examples of org.newdawn.slick.opengl.LoadableImageData


   * @param tileSize The maximum size of the tiles to use to build the bigger image
   * @throws SlickException Indicates we were unable to locate the resource
   */
  private void build(String ref, int filter, int tileSize) throws SlickException {
    try {
      final LoadableImageData data = ImageDataFactory.getImageDataFor(ref);
      final ByteBuffer imageBuffer = data.loadImage(ResourceLoader.getResourceAsStream(ref), false, null);
      build(data, imageBuffer, filter, tileSize);
    } catch (IOException e) {
      throw new SlickException("Failed to load: "+ref, e);
    }
  }
View Full Code Here


   * @see org.newdawn.slick.GameContainer#setIcons(java.lang.String[])
   */
  public void setIcons(String[] refs) throws SlickException {
    ByteBuffer[] bufs = new ByteBuffer[refs.length];
    for (int i=0;i<refs.length;i++) {
      LoadableImageData data;
      boolean flip = true;
     
      if (refs[i].endsWith(".tga")) {
        data = new TGAImageData();
      } else {
        flip = false;
        data = new ImageIOImageData();
      }
     
      try {
        bufs[i] = data.loadImage(ResourceLoader.getResourceAsStream(refs[i]), flip, false, null);
      } catch (Exception e) {
        Log.error(e);
        throw new SlickException("Failed to set the icon");
      }
    }
View Full Code Here

   * @see org.newdawn.slick.GameContainer#setIcons(java.lang.String[])
   */
  public void setIcons(String[] refs) throws SlickException {
    ByteBuffer[] bufs = new ByteBuffer[refs.length];
    for (int i = 0; i < refs.length; i++) {
      LoadableImageData data;
      boolean flip = true;

      if (refs[i].endsWith(".tga")) {
        data = new TGAImageData();
      } else {
        flip = false;
        data = new ImageIOImageData();
      }

      try {
        bufs[i] = data.loadImage(ResourceLoader
            .getResourceAsStream(refs[i]), flip, false, null);
      } catch (Exception e) {
        Log.error(e);
        throw new SlickException("Failed to set the icon");
      }
View Full Code Here

   * @param tileSize The maximum size of the tiles to use to build the bigger image
   * @throws SlickException Indicates we were unable to locate the resource
   */
  private void build(String ref, int filter, int tileSize) throws SlickException {
    try {
      final LoadableImageData data = ImageDataFactory.getImageDataFor(ref);
      final ByteBuffer imageBuffer = data.loadImage(ResourceLoader.getResourceAsStream(ref), false, null);
      final int dataWidth = data.getTexWidth();
      final int dataHeight = data.getTexHeight();
     
      realWidth = width = data.getWidth();
      realHeight = height = data.getHeight();
     
      if ((dataWidth <= tileSize) && (dataHeight <= tileSize)) {
        images = new Image[1][1];
        ImageData tempData = new ImageData() {
          public int getDepth() {
            return data.getDepth();
          }

          public int getHeight() {
            return dataHeight;
          }

          public ByteBuffer getImageBufferData() {
            return imageBuffer;
          }

          public int getTexHeight() {
            return dataHeight;
          }

          public int getTexWidth() {
            return dataWidth;
          }

          public int getWidth() {
            return dataWidth;
          }
        };
        images[0][0] = new Image(tempData, filter);
        xcount = 1;
        ycount = 1;
        inited = true;
        return;
      }
     
      xcount = ((dataWidth-1) / tileSize) + 1;
      ycount = ((dataHeight-1) / tileSize) + 1;
     
      images = new Image[xcount][ycount];
      int components = data.getDepth() / 8;
     
      for (int x=0;x<xcount;x++) {
        for (int y=0;y<ycount;y++) {
          final int xSize = tileSize;
          final int ySize = tileSize;
         
          final ByteBuffer subBuffer = BufferUtils.createByteBuffer(tileSize*tileSize*components);
          int xo = x*tileSize*components;
 
          byte[] byteData = new byte[xSize*components];
          for (int i=0;i<ySize;i++) {
            int yo = (((y * tileSize) + i) * dataWidth) * components;
            imageBuffer.position(yo+xo);
           
            imageBuffer.get(byteData, 0, xSize*components);
            subBuffer.put(byteData);
          }
         
          int finalX = ((x) * tileSize);
          int finalY = ((y) * tileSize);
          final int imageWidth = realWidth < finalX ? realWidth % tileSize : tileSize;
          final int imageHeight = realHeight < finalY ? realHeight % tileSize : tileSize;
         
          subBuffer.flip();
          ImageData imgData = new ImageData() {
            public int getDepth() {
              return data.getDepth();
            }
 
            public int getHeight() {
              return imageHeight;
            }
View Full Code Here

   * @param tileSize The maximum size of the tiles to use to build the bigger image
   * @throws SlickException Indicates we were unable to locate the resource
   */
  private void build(String ref, int filter, int tileSize) throws SlickException {
    try {
      final LoadableImageData data = ImageDataFactory.getImageDataFor(ref);
      final ByteBuffer imageBuffer = data.loadImage(ResourceLoader.getResourceAsStream(ref), false, null);
      build(data, imageBuffer, filter, tileSize);
    } catch (IOException e) {
      throw new SlickException("Failed to load: "+ref, e);
    }
  }
View Full Code Here

   * @see org.newdawn.slick.GameContainer#setIcons(java.lang.String[])
   */
  public void setIcons(String[] refs) throws SlickException {
    ByteBuffer[] bufs = new ByteBuffer[refs.length];
    for (int i=0;i<refs.length;i++) {
      LoadableImageData data;
      boolean flip = true;
     
      if (refs[i].endsWith(".tga")) {
        data = new TGAImageData();
      } else {
        flip = false;
        data = new ImageIOImageData();
      }
     
      try {
        bufs[i] = data.loadImage(ResourceLoader.getResourceAsStream(refs[i]), flip, false, null);
      } catch (Exception e) {
        Log.error(e);
        throw new SlickException("Failed to set the icon");
      }
    }
View Full Code Here

   * @param tileSize The maximum size of the tiles to use to build the bigger image
   * @throws SlickException Indicates we were unable to locate the resource
   */
  private void build(String ref, int filter, int tileSize) throws SlickException {
    try {
      final LoadableImageData data = ImageDataFactory.getImageDataFor(ref);
      final ByteBuffer imageBuffer = data.loadImage(ResourceLoader.getResourceAsStream(ref), false, null);
      build(data, imageBuffer, filter, tileSize);
    } catch (IOException e) {
      throw new SlickException("Failed to load: "+ref, e);
    }
  }
View Full Code Here

   * @see org.newdawn.slick.GameContainer#setIcons(java.lang.String[])
   */
  public void setIcons(String[] refs) throws SlickException {
    ByteBuffer[] bufs = new ByteBuffer[refs.length];
    for (int i=0;i<refs.length;i++) {
      LoadableImageData data;
      boolean flip = true;
     
      if (refs[i].endsWith(".tga")) {
        data = new TGAImageData();
      } else {
        flip = false;
        data = new ImageIOImageData();
      }
     
      try {
        bufs[i] = data.loadImage(ResourceLoader.getResourceAsStream(refs[i]), flip, false, null);
      } catch (Exception e) {
        Log.error(e);
        throw new SlickException("Failed to set the icon");
      }
    }
View Full Code Here

TOP

Related Classes of org.newdawn.slick.opengl.LoadableImageData

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.