java.awt.image.AffineTransformOp Java Examples
The following examples show how to use
java.awt.image.AffineTransformOp.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DrawImage.java From Bytecoder with Apache License 2.0 | 6 votes |
public void transformImage(SunGraphics2D sg, BufferedImage img, BufferedImageOp op, int x, int y) { if (op != null) { if (op instanceof AffineTransformOp) { AffineTransformOp atop = (AffineTransformOp) op; transformImage(sg, img, x, y, atop.getTransform(), atop.getInterpolationType()); return; } else { img = op.filter(img, null); } } copyImage(sg, img, x, y, null); }
Example #2
Source File: DrawImage.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public void transformImage(SunGraphics2D sg, BufferedImage img, BufferedImageOp op, int x, int y) { if (op != null) { if (op instanceof AffineTransformOp) { AffineTransformOp atop = (AffineTransformOp) op; transformImage(sg, img, x, y, atop.getTransform(), atop.getInterpolationType()); return; } else { img = op.filter(img, null); } } copyImage(sg, img, x, y, null); }
Example #3
Source File: D3DDrawImage.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override public void transformImage(SunGraphics2D sg, BufferedImage img, BufferedImageOp op, int x, int y) { if (op != null) { if (op instanceof AffineTransformOp) { AffineTransformOp atop = (AffineTransformOp) op; transformImage(sg, img, x, y, atop.getTransform(), atop.getInterpolationType()); return; } else { if (D3DBufImgOps.renderImageWithOp(sg, img, op, x, y)) { return; } } img = op.filter(img, null); } copyImage(sg, img, x, y, null); }
Example #4
Source File: Imager.java From boubei-tss with Apache License 2.0 | 6 votes |
public static void zoomImage(String src, Integer maxPicSize) throws Exception { File srcFile = new File(src); long fileSize = srcFile.length(); String subfix = FileHelper.getFileSuffix(srcFile.getName()); List<String> list = Arrays.asList( "jpg,jpeg,bmp,gif".split(",") ); // 这些格式支持有损压缩,png等不支持 if (fileSize <= maxPicSize * 1024 || !list.contains(subfix.toLowerCase())) { // 文件本身已小于size(K)时,不做缩放 return; } Double rate = (maxPicSize * 1024.0) / fileSize; // 获取长宽缩放比例 rate = Math.max(rate, 0.5); BufferedImage bufImg = ImageIO.read(srcFile); Image Itemp = bufImg.getScaledInstance(bufImg.getWidth(), bufImg.getHeight(), Image.SCALE_SMOOTH); AffineTransformOp ato = new AffineTransformOp(AffineTransform.getScaleInstance(rate, rate), null); Itemp = ato.filter(bufImg, null); ImageIO.write((BufferedImage) Itemp, subfix, srcFile); }
Example #5
Source File: DrawImage.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static boolean isSimpleTranslate(SunGraphics2D sg) { int ts = sg.transformState; if (ts <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) { // Integer translates are always "simple" return true; } if (ts >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) { // Scales and beyond are always "not simple" return false; } // non-integer translates are only simple when not interpolating if (sg.interpolationType == AffineTransformOp.TYPE_NEAREST_NEIGHBOR) { return true; } return false; }
Example #6
Source File: DrawImage.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public static boolean isSimpleTranslate(SunGraphics2D sg) { int ts = sg.transformState; if (ts <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) { // Integer translates are always "simple" return true; } if (ts >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) { // Scales and beyond are always "not simple" return false; } // non-integer translates are only simple when not interpolating if (sg.interpolationType == AffineTransformOp.TYPE_NEAREST_NEIGHBOR) { return true; } return false; }
Example #7
Source File: D3DDrawImage.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public void transformImage(SunGraphics2D sg, BufferedImage img, BufferedImageOp op, int x, int y) { if (op != null) { if (op instanceof AffineTransformOp) { AffineTransformOp atop = (AffineTransformOp) op; transformImage(sg, img, x, y, atop.getTransform(), atop.getInterpolationType()); return; } else { if (D3DBufImgOps.renderImageWithOp(sg, img, op, x, y)) { return; } } img = op.filter(img, null); } copyImage(sg, img, x, y, null); }
Example #8
Source File: AbstractJaiTest.java From java-image-processing-survival-guide with Apache License 2.0 | 6 votes |
/** * Some quick and dirty image scaling - please note that for best performance * and quality you should use image rescaling libraries. */ @Override public BufferedImage resample(BufferedImage bufferedImage, int width, int height) { Dimension imageDimension = new Dimension(bufferedImage.getWidth(), bufferedImage.getHeight()); Dimension boundaryDimension = new Dimension(width, height); Dimension scaledDimension = BufferedImageUtils.getScaledDimension(imageDimension, boundaryDimension); double scaleX = scaledDimension.getWidth() / bufferedImage.getWidth(); double scaleY = scaledDimension.getHeight() / bufferedImage.getHeight(); AffineTransform scaleTransform = AffineTransform.getScaleInstance(scaleX, scaleY); AffineTransformOp biLinearScaleOp = new AffineTransformOp(scaleTransform, AffineTransformOp.TYPE_BILINEAR); return biLinearScaleOp.filter( bufferedImage, new BufferedImage(scaledDimension.width, scaledDimension.height, bufferedImage.getType())); }
Example #9
Source File: OGLDrawImage.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public void transformImage(SunGraphics2D sg, BufferedImage img, BufferedImageOp op, int x, int y) { if (op != null) { if (op instanceof AffineTransformOp) { AffineTransformOp atop = (AffineTransformOp) op; transformImage(sg, img, x, y, atop.getTransform(), atop.getInterpolationType()); return; } else { if (OGLBufImgOps.renderImageWithOp(sg, img, op, x, y)) { return; } } img = op.filter(img, null); } copyImage(sg, img, x, y, null); }
Example #10
Source File: D3DDrawImage.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override public void transformImage(SunGraphics2D sg, BufferedImage img, BufferedImageOp op, int x, int y) { if (op != null) { if (op instanceof AffineTransformOp) { AffineTransformOp atop = (AffineTransformOp) op; transformImage(sg, img, x, y, atop.getTransform(), atop.getInterpolationType()); return; } else { if (D3DBufImgOps.renderImageWithOp(sg, img, op, x, y)) { return; } } img = op.filter(img, null); } copyImage(sg, img, x, y, null); }
Example #11
Source File: Util.java From r2cloud with Apache License 2.0 | 6 votes |
public static void rotateImage(File result) { try { BufferedImage image; try (FileInputStream fis = new FileInputStream(result)) { image = ImageIO.read(fis); } AffineTransform tx = AffineTransform.getScaleInstance(-1, -1); tx.translate(-image.getWidth(null), -image.getHeight(null)); AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); image = op.filter(image, null); try (FileOutputStream fos = new FileOutputStream(result)) { ImageIO.write(image, "jpg", fos); } } catch (Exception e) { LOG.error("unable to rotate image", e); } }
Example #12
Source File: D3DBlitLoops.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) { D3DBlitLoops.Blit(src, dst, comp, clip, null, AffineTransformOp.TYPE_NEAREST_NEIGHBOR, sx, sy, sx+w, sy+h, dx, dy, dx+w, dy+h, typeval, false); }
Example #13
Source File: OGLBlitLoops.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) { OGLBlitLoops.IsoBlit(src, dst, null, null, comp, clip, null, AffineTransformOp.TYPE_NEAREST_NEIGHBOR, sx, sy, sx+w, sy+h, dx, dy, dx+w, dy+h, false); }
Example #14
Source File: D3DBlitLoops.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) { D3DBlitLoops.IsoBlit(src, dst, null, null, comp, clip, null, AffineTransformOp.TYPE_NEAREST_NEIGHBOR, sx, sy, sx+w, sy+h, dx, dy, dx+w, dy+h, true); }
Example #15
Source File: OGLBlitLoops.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public void Scale(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx1, int sy1, int sx2, int sy2, double dx1, double dy1, double dx2, double dy2) { OGLBlitLoops.Blit(src, dst, comp, clip, null, AffineTransformOp.TYPE_NEAREST_NEIGHBOR, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2, typeval, false); }
Example #16
Source File: OGLBlitLoops.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void Scale(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx1, int sy1, int sx2, int sy2, double dx1, double dy1, double dx2, double dy2) { OGLBlitLoops.IsoBlit(src, dst, null, null, comp, clip, null, AffineTransformOp.TYPE_NEAREST_NEIGHBOR, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2, false); }
Example #17
Source File: JXLayer.java From javamelody with Apache License 2.0 | 5 votes |
/** * @param bufferedImageOp BufferedImageOp */ public void setBufferedImageOp(BufferedImageOp bufferedImageOp) { if (bufferedImageOp instanceof AffineTransformOp) { throw new IllegalArgumentException("AffineTransformOp is not supported"); } this.bio = bufferedImageOp; repaint(); }
Example #18
Source File: OGLBlitLoops.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) { OGLBlitLoops.IsoBlit(src, dst, null, null, comp, clip, null, AffineTransformOp.TYPE_NEAREST_NEIGHBOR, sx, sy, sx+w, sy+h, dx, dy, dx+w, dy+h, false); }
Example #19
Source File: D3DBlitLoops.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) { D3DBlitLoops.IsoBlit(src, dst, null, null, comp, clip, null, AffineTransformOp.TYPE_NEAREST_NEIGHBOR, sx, sy, sx+w, sy+h, dx, dy, dx+w, dy+h, false); }
Example #20
Source File: SunGraphics2D.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public SunGraphics2D(SurfaceData sd, Color fg, Color bg, Font f) { surfaceData = sd; foregroundColor = fg; backgroundColor = bg; transform = new AffineTransform(); stroke = defaultStroke; composite = defaultComposite; paint = foregroundColor; imageComp = CompositeType.SrcOverNoEa; renderHint = SunHints.INTVAL_RENDER_DEFAULT; antialiasHint = SunHints.INTVAL_ANTIALIAS_OFF; textAntialiasHint = SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT; fractionalMetricsHint = SunHints.INTVAL_FRACTIONALMETRICS_OFF; lcdTextContrast = lcdTextContrastDefaultValue; interpolationHint = -1; strokeHint = SunHints.INTVAL_STROKE_DEFAULT; resolutionVariantHint = SunHints.INTVAL_RESOLUTION_VARIANT_DEFAULT; interpolationType = AffineTransformOp.TYPE_NEAREST_NEIGHBOR; validateColor(); devScale = sd.getDefaultScale(); if (devScale != 1) { transform.setToScale(devScale, devScale); invalidateTransform(); } font = f; if (font == null) { font = defaultFont; } setDevClip(sd.getBounds()); invalidatePipe(); }
Example #21
Source File: RenderUtils.java From jaamsim with Apache License 2.0 | 5 votes |
/** * Scale an awt BufferedImage to a given resolution * @param img * @param newWidth * @param newHeight * @return a new BufferedImage of the appropriate size */ public static BufferedImage scaleToRes(BufferedImage img, int newWidth, int newHeight) { int oldWidth = img.getWidth(); int oldHeight = img.getHeight(); BufferedImage ret = new BufferedImage(newWidth, newHeight, BufferedImage.TYPE_INT_ARGB); AffineTransform at = new AffineTransform(); at.scale((double)newWidth/(double)oldWidth, (double)newHeight/(double)oldHeight); AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); ret = scaleOp.filter(img, ret); return ret; }
Example #22
Source File: OGLBlitLoops.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) { OGLBlitLoops.Blit(src, dst, comp, clip, null, AffineTransformOp.TYPE_NEAREST_NEIGHBOR, sx, sy, sx+w, sy+h, dx, dy, dx+w, dy+h, typeval, false); }
Example #23
Source File: D3DBlitLoops.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) { D3DBlitLoops.Blit(src, dst, comp, clip, null, AffineTransformOp.TYPE_NEAREST_NEIGHBOR, sx, sy, sx+w, sy+h, dx, dy, dx+w, dy+h, typeval, false); }
Example #24
Source File: D3DBlitLoops.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) { D3DBlitLoops.IsoBlit(src, dst, null, null, comp, clip, null, AffineTransformOp.TYPE_NEAREST_NEIGHBOR, sx, sy, sx+w, sy+h, dx, dy, dx+w, dy+h, false); }
Example #25
Source File: D3DBlitLoops.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void Scale(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx1, int sy1, int sx2, int sy2, double dx1, double dy1, double dx2, double dy2) { D3DBlitLoops.IsoBlit(src, dst, null, null, comp, clip, null, AffineTransformOp.TYPE_NEAREST_NEIGHBOR, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2, false); }
Example #26
Source File: D3DBlitLoops.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public void Scale(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx1, int sy1, int sx2, int sy2, double dx1, double dy1, double dx2, double dy2) { D3DBlitLoops.IsoBlit(src, dst, null, null, comp, clip, null, AffineTransformOp.TYPE_NEAREST_NEIGHBOR, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2, false); }
Example #27
Source File: D3DDrawImage.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override protected void renderImageXform(SunGraphics2D sg, Image img, AffineTransform tx, int interpType, int sx1, int sy1, int sx2, int sy2, Color bgColor) { // punt to the MediaLib-based transformImage() in the superclass if: // - bicubic interpolation is specified // - a background color is specified and will be used // - an appropriate TransformBlit primitive could not be found if (interpType != AffineTransformOp.TYPE_BICUBIC) { SurfaceData dstData = sg.surfaceData; SurfaceData srcData = dstData.getSourceSurfaceData(img, SunGraphics2D.TRANSFORM_GENERIC, sg.imageComp, bgColor); if (srcData != null && !isBgOperation(srcData, bgColor)) { SurfaceType srcType = srcData.getSurfaceType(); SurfaceType dstType = dstData.getSurfaceType(); TransformBlit blit = TransformBlit.getFromCache(srcType, sg.imageComp, dstType); if (blit != null) { blit.Transform(srcData, dstData, sg.composite, sg.getCompClip(), tx, interpType, sx1, sy1, 0, 0, sx2-sx1, sy2-sy1); return; } } } super.renderImageXform(sg, img, tx, interpType, sx1, sy1, sx2, sy2, bgColor); }
Example #28
Source File: D3DBlitLoops.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) { D3DBlitLoops.IsoBlit(src, dst, null, null, comp, clip, null, AffineTransformOp.TYPE_NEAREST_NEIGHBOR, sx, sy, sx+w, sy+h, dx, dy, dx+w, dy+h, true); }
Example #29
Source File: OGLBlitLoops.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public void Blit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) { OGLBlitLoops.Blit(src, dst, comp, clip, null, AffineTransformOp.TYPE_NEAREST_NEIGHBOR, sx, sy, sx+w, sy+h, dx, dy, dx+w, dy+h, typeval, true); }
Example #30
Source File: SunGraphics2D.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public SunGraphics2D(SurfaceData sd, Color fg, Color bg, Font f) { surfaceData = sd; foregroundColor = fg; backgroundColor = bg; transform = new AffineTransform(); stroke = defaultStroke; composite = defaultComposite; paint = foregroundColor; imageComp = CompositeType.SrcOverNoEa; renderHint = SunHints.INTVAL_RENDER_DEFAULT; antialiasHint = SunHints.INTVAL_ANTIALIAS_OFF; textAntialiasHint = SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT; fractionalMetricsHint = SunHints.INTVAL_FRACTIONALMETRICS_OFF; lcdTextContrast = lcdTextContrastDefaultValue; interpolationHint = -1; strokeHint = SunHints.INTVAL_STROKE_DEFAULT; interpolationType = AffineTransformOp.TYPE_NEAREST_NEIGHBOR; validateColor(); devScale = sd.getDefaultScale(); if (devScale != 1) { transform.setToScale(devScale, devScale); invalidateTransform(); } font = f; if (font == null) { font = defaultFont; } setDevClip(sd.getBounds()); invalidatePipe(); }