예제 #1
0
 @Override
 public Surface drawImage(Image image, float x, float y, float dw, float dh) {
   bindFramebuffer();
   ((ImageGL) image)
       .draw(shader, topTransform(), x, y, dw, dh, 0, 0, image.width(), image.height(), tint);
   return this;
 }
예제 #2
0
 /**
  * Creates a new background using the given image. The image is assumed to be divided into a 3x1
  * grid of 3 equal pieces.
  *
  * <p>NOTE: the image must be preloaded since we need to determine the stretching factor. If this
  * cannot be arranged using the application resource strategy, callers may consider setting the
  * background style from the images callback.
  */
 public Scale3Background(Image image) {
   if (!image.isReady()) {
     // complain about this, we don't support asynch images
     PlayN.log().warn("Scale3 image not preloaded: " + image);
   }
   _image = image;
   _s3 = new Scale3(image.width(), image.height());
 }
예제 #3
0
  // used by GLContext.tex(Sub)Image2D impls
  protected static ByteBuffer getRgba(Image image) {
    int w = (int) image.width(), h = (int) image.height(), size = w * h;
    int[] rawPixels = new int[size];
    ByteBuffer pixels = ByteBuffer.allocateDirect(size * 4);
    pixels.order(ByteOrder.nativeOrder());
    IntBuffer rgba = pixels.asIntBuffer();
    image.getRgb(0, 0, w, h, rawPixels, 0, w);

    for (int i = 0; i < size; i++) {
      int argb = rawPixels[i];
      // Order is inverted because this is read as a byte array, and we store intel ints.
      rgba.put(i, ((argb >> 16) & 0x0ff) | (argb & 0x0ff00ff00) | ((argb & 0xff) << 16));
    }
    return pixels;
  }
예제 #4
0
 @Override
 public Surface drawImageCentered(Image img, float x, float y) {
   return drawImage(img, x - img.width() / 2, y - img.height() / 2);
 }
예제 #5
0
 @Override
 public Surface drawImage(Image image, float x, float y) {
   return drawImage(image, x, y, image.width(), image.height());
 }
예제 #6
0
 public int getHeight() {
   if (image != null) return image.height();
   return 1;
 }
예제 #7
0
 /**
  * Creates an instance with the supplied source image. The image is assumed to contain a complete
  * sheet of frames, each {@code width x height} in size.
  *
  * @param width the width of each frame.
  * @param height the width of each frame.
  */
 public SimpleFrames(Image source, float width, float height) {
   this(source, width, height, (int) (source.height() / height) * (int) (source.width() / width));
 }
예제 #8
0
 /**
  * Creates an instance with the supplied source image. The frames are assumed to be all in a
  * single row, thus the height of the image defines the height of the frame.
  *
  * @param width the width of each frame.
  */
 public SimpleFrames(Image source, float width) {
   this(source, width, source.height());
 }