/** * Uses a ImageFilter to return a cropped version of the image. Hopefully useful when handling * tilesets. */ public static Image getTile(Image tileset, int x1, int x2, int y1, int y2, int scale) { JPanel producer = new JPanel(); // Crop tileset to grab tile ImageFilter cropper = new CropImageFilter(x1, y1, x2 - x1, y2 - y1); Image cropped = producer.createImage(new FilteredImageSource(tileset.getSource(), cropper)); return scaleImage(cropped, scale); }