List of utility methods to do Image Cut
Image | cropImage(Image image, int x, int y, int width, int height) crop Image return Toolkit.getDefaultToolkit().createImage( new FilteredImageSource(image.getSource(), new CropImageFilter(x, y, width, height))); |
Image | cropImage(Image img, int x, int y, int w, int h) crop Image BufferedImage out = createImage(w, h);
Graphics g = out.getGraphics();
BufferedImage sub = ((BufferedImage) img).getSubimage(x, y, w, h);
g.drawImage(sub, 0, 0, w, h, null);
g.dispose();
return out;
|
Image | cropImage(Image originalImage, int left, int top, int right, int bottom) Crops the edges of the image, as specified. BufferedImage newImage = new BufferedImage(originalImage.getWidth(null) - left - right, originalImage.getHeight(null) - top - bottom, BufferedImage.TYPE_INT_ARGB_PRE); Graphics2D g2d = newImage.createGraphics(); g2d.setRenderingHints(RENDERING_HINTS_HIGH_QUALITY); g2d.drawImage(originalImage, -1 * left, -1 * top, null); g2d.dispose(); return newImage; |
void | cropImage(URL url, float x, float y, float w, float h, OutputStream out) crop Image InputStream in = url.openStream(); try { cropImage(in, x, y, w, h, out); } finally { in.close(); |
void | cut(String srcImageFile, String result, int x, int y, int width, int height) cut try { BufferedImage bi = ImageIO.read(new File(srcImageFile)); int srcWidth = bi.getHeight(); int srcHeight = bi.getWidth(); if ((srcWidth > 0) && (srcHeight > 0)) { Image image = bi.getScaledInstance(srcWidth, srcHeight, 1); ImageFilter cropFilter = new CropImageFilter(x, y, width, height); Image img = Toolkit.getDefaultToolkit() ... |
void | cut2(String srcImageFile, String descDir, int rows, int cols) cut try { if ((rows <= 0) || (rows > 20)) { rows = 2; if ((cols <= 0) || (cols > 20)) { cols = 2; BufferedImage bi = ImageIO.read(new File(srcImageFile)); ... |
BufferedImage | cutImage(BufferedImage image, int posX, int posY, int width, int height) cut Image return image.getSubimage(posX, posY, width, height);
|
BufferedImage[] | cutImage(BufferedImage img, int w, int h) cut Image int cols = img.getWidth() / w; int rows = img.getHeight() / h; BufferedImage[] tiles = new BufferedImage[cols * rows]; for (int x = 0; x < cols; x++) { for (int y = 0; y < rows; y++) { tiles[x + y * cols] = img.getSubimage(x * w, y * h, w, h); return tiles; |
void | cutImage(File file, int x, int y, int width, int heigth) cut Image String fileName = file.getName(); String prefix = fileName.substring(fileName.lastIndexOf(".") + 1); Iterator<?> iterator = ImageIO.getImageReadersByFormatName(prefix); ImageReader reader = (ImageReader) iterator.next(); InputStream in = new FileInputStream(file); ImageInputStream iis = ImageIO.createImageInputStream(in); reader.setInput(iis, true); ImageReadParam param = reader.getDefaultReadParam(); ... |
BufferedImage | cutImage(final BufferedImage bufferedImage, final int targetW, final int targetH) cut Image int sourceWidth = bufferedImage.getWidth(); int sourceHeight = bufferedImage.getHeight(); int dw = targetW, dh = targetH; if (targetW > sourceWidth) { dw = sourceWidth; if (targetH > sourceHeight) { dh = sourceHeight; ... |