View Javadoc
1   package org.newdawn.slick.opengl;
2   
3   import java.nio.ByteBuffer;
4   
5   import org.lwjgl.BufferUtils;
6   
7   import javax.annotation.Nonnull;
8   
9   /**
10   * An image data implementation which represents an empty texture
11   * 
12   * @author kevin
13   */
14  public class EmptyImageData implements ImageData {
15      /** The width of the data */
16      private final int width;
17      /** The height of the data */
18      private final int height;
19  
20      /**
21       * Create an empty image data source
22       *
23       * @param width The width of the source
24       * @param height The height of the source
25       */
26      public EmptyImageData(int width, int height) {
27          this.width = width;
28          this.height = height;
29      }
30  
31      /**
32       * @see org.newdawn.slick.opengl.ImageData#getFormat()
33       */
34      @Nonnull
35      public Format getFormat() {
36          return Format.RGBA;
37      }
38  
39      /**
40       * @see org.newdawn.slick.opengl.ImageData#getHeight()
41       */
42      public int getHeight() {
43          return height;
44      }
45  
46      /**
47       * @see org.newdawn.slick.opengl.ImageData#getImageBufferData()
48       */
49      public ByteBuffer getImageBufferData() {
50          return BufferUtils.createByteBuffer(getTexWidth() * getTexHeight() * 4);
51      }
52  
53      /**
54       * @see org.newdawn.slick.opengl.ImageData#getTexHeight()
55       */
56      public int getTexHeight() {
57          return InternalTextureLoader.get2Fold(height);
58      }
59  
60      /**
61       * @see org.newdawn.slick.opengl.ImageData#getTexWidth()
62       */
63      public int getTexWidth() {
64          return InternalTextureLoader.get2Fold(width);
65      }
66  
67      /**
68       * @see org.newdawn.slick.opengl.ImageData#getWidth()
69       */
70      public int getWidth() {
71          return width;
72      }
73  
74  }