@Override public BufferedImage doTransform(BufferedImage src, BufferedImage dest) { dest = ImageUtils.copyImage(src); Color color = colorParam.getColor(); int width = widthParam.getValue(); int spacing = spacingParam.getValue(); boolean emptyIntersections = emptyIntersectionsParam.isChecked(); Graphics2D g = dest.createGraphics(); int destWidth = dest.getWidth(); int destHeight = dest.getHeight(); float opacity = opacityParam.getValueAsPercentage(); boolean rotated = !rotateResult.isSetToDefault(); int maxX = destWidth; int maxY = destHeight; // if(rotated) { // maxX = (int) (Math.max(destWidth, destHeight) * 1.3); // maxY = maxX; // } // we draw the grid first on an image with transparent background BufferedImage tmp = ImageUtils.getGridImageOnTransparentBackground( color, maxX, maxY, width, spacing, width, spacing, emptyIntersections); g.setComposite(AlphaComposite.getInstance(SRC_ATOP, opacity)); if (rotated) { g.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON); g.setRenderingHint(KEY_INTERPOLATION, VALUE_INTERPOLATION_BILINEAR); g.translate(maxX / 2, maxY / 2); g.rotate(rotateResult.getValueInRadians()); int xDiff = maxX - destWidth; int yDiff = maxY - destHeight; g.translate(-xDiff / 2, -yDiff / 2); g.translate(-maxX / 2 / 2, -maxY / 2 / 2); } g.drawImage(tmp, 0, 0, null); g.dispose(); return dest; }
@Override public BufferedImage doTransform(BufferedImage src, BufferedImage dest) { // fill with the background color Graphics2D g = dest.createGraphics(); g.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON); g.setRenderingHint(KEY_INTERPOLATION, VALUE_INTERPOLATION_BICUBIC); g.setColor(bgColorParam.getColor()); g.fillRect(0, 0, dest.getWidth(), dest.getHeight()); double theta = angleParam.getValueInRadians(); ImageLayer layer = ImageComponents.getActiveImageLayerOrMask().get(); float relativeX = centerParam.getRelativeX(); float relativeY = centerParam.getRelativeY(); double centerShiftX = (-layer.getTX() + src.getWidth()) * relativeX; double centerShiftY = (-layer.getTY() + src.getHeight()) * relativeY; AffineTransform transform = AffineTransform.getRotateInstance(theta, centerShiftX, centerShiftY); int scaleX = scaleParam.getValue(0); int scaleY = scaleParam.getValue(1); if ((scaleX != 100) || (scaleY != 100)) { transform.translate(centerShiftX, centerShiftY); transform.scale(scaleX / 100.0, scaleY / 100.0); transform.translate(-centerShiftX, -centerShiftY); } int shearX = shearParam.getValue(0); int shearY = shearParam.getValue(1); if ((shearX != 0) || (shearY != 0)) { transform.translate(centerShiftX, centerShiftY); transform.shear(shearX / 100.0, shearY / 100.0); transform.translate(-centerShiftX, -centerShiftY); } g.drawImage(src, transform, null); g.dispose(); return dest; }
@Override public BufferedImage doTransform(BufferedImage src, BufferedImage dest) { if (filter == null) { filter = new CheckFilter(); } // filter.setAaRes(aaRes.getValue()); filter.setFuzziness(fuzziness.getValue()); filter.setAngle((float) angle.getValueInRadians()); filter.setBackground(color1.getColor().getRGB()); filter.setForeground(color2.getColor().getRGB()); filter.setXScale(size.getValue(0)); filter.setYScale(size.getValue(1)); dest = filter.filter(src, dest); if (bumpMap.isChecked()) { return ImageUtils.bumpMap(src, dest); } return dest; }