/** * Creates the image strip. * * @param strip the strip * @param cols the cols * @param rows the rows * @return the queue */ public static Queue<Image> createImageStrip(Image strip, int cols, int rows) { int imgWidth = strip.getBounds().width; int imgHeight = strip.getBounds().height; int tileWidth = imgWidth / cols; int tileHeight = imgHeight / rows; Queue<Image> imgStip = new LinkedList<Image>(); for (int y = 0; y < imgHeight; y += tileHeight) { for (int x = 0; x < imgWidth; x += tileWidth) { Rectangle r = new Rectangle(x, y, tileWidth, tileHeight); final ImageData id = ResourceManager.extractImageFromBounds(strip.getImageData(), r); Image extractImage = ResourceManager.getImage(id); imgStip.add(extractImage); } } return imgStip; }
/** * Scale image. * * @param id the id * @param scaleFactor the scale factor * @return the image */ public static Image scaleImage(final ImageData id, float scaleFactor) { final int w = (int) (id.width * scaleFactor); final int h = (int) (id.height * scaleFactor); return ResourceManager.getImage(id.scaledTo(w, h)); }