Java Code Examples for sun.java2d.pipe.Region#getHiX()
The following examples show how to use
sun.java2d.pipe.Region#getHiX() .
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: GDIWindowSurfaceData.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, int dx, int dy) { CompositeType comptype = sg2d.imageComp; if (sg2d.clipState != SunGraphics2D.CLIP_SHAPE && (CompositeType.SrcOverNoEa.equals(comptype) || CompositeType.SrcNoEa.equals(comptype))) { int dstx1 = x + dx; int dsty1 = y + dy; int dstx2 = dstx1 + w; int dsty2 = dsty1 + h; Region clip = sg2d.getCompClip(); if (dstx1 < clip.getLoX()) dstx1 = clip.getLoX(); if (dsty1 < clip.getLoY()) dsty1 = clip.getLoY(); if (dstx2 > clip.getHiX()) dstx2 = clip.getHiX(); if (dsty2 > clip.getHiY()) dsty2 = clip.getHiY(); if (dstx1 < dstx2 && dsty1 < dsty2) { gdiPipe.devCopyArea(this, dstx1 - dx, dsty1 - dy, dx, dy, dstx2 - dstx1, dsty2 - dsty1); } return true; } return false; }
Example 2
Source File: DrawGlyphListAA.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData dest, GlyphList gl) { gl.getBounds(); // Don't delete, bug 4895493 int num = gl.getNumGlyphs(); Region clip = sg2d.getCompClip(); int cx1 = clip.getLoX(); int cy1 = clip.getLoY(); int cx2 = clip.getHiX(); int cy2 = clip.getHiY(); for (int i = 0; i < num; i++) { gl.setGlyphIndex(i); int metrics[] = gl.getMetrics(); int gx1 = metrics[0]; int gy1 = metrics[1]; int w = metrics[2]; int gx2 = gx1 + w; int gy2 = gy1 + metrics[3]; int off = 0; if (gx1 < cx1) { off = cx1 - gx1; gx1 = cx1; } if (gy1 < cy1) { off += (cy1 - gy1) * w; gy1 = cy1; } if (gx2 > cx2) gx2 = cx2; if (gy2 > cy2) gy2 = cy2; if (gx2 > gx1 && gy2 > gy1) { byte alpha[] = gl.getGrayBits(); maskop.MaskFill(sg2d, dest, sg2d.composite, gx1, gy1, gx2 - gx1, gy2 - gy1, alpha, off, w); } } }
Example 3
Source File: GeneralRenderer.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public PixelWriterDrawHandler(SurfaceData sData, PixelWriter pw, Region clip, int strokeHint) { super(clip.getLoX(), clip.getLoY(), clip.getHiX(), clip.getHiY(), strokeHint); this.sData = sData; this.pw = pw; this.clip = clip; }
Example 4
Source File: GDIWindowSurfaceData.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, int dx, int dy) { CompositeType comptype = sg2d.imageComp; if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE && sg2d.clipState != sg2d.CLIP_SHAPE && (CompositeType.SrcOverNoEa.equals(comptype) || CompositeType.SrcNoEa.equals(comptype))) { x += sg2d.transX; y += sg2d.transY; int dstx1 = x + dx; int dsty1 = y + dy; int dstx2 = dstx1 + w; int dsty2 = dsty1 + h; Region clip = sg2d.getCompClip(); if (dstx1 < clip.getLoX()) dstx1 = clip.getLoX(); if (dsty1 < clip.getLoY()) dsty1 = clip.getLoY(); if (dstx2 > clip.getHiX()) dstx2 = clip.getHiX(); if (dsty2 > clip.getHiY()) dsty2 = clip.getHiY(); if (dstx1 < dstx2 && dsty1 < dsty2) { gdiPipe.devCopyArea(this, dstx1 - dx, dsty1 - dy, dx, dy, dstx2 - dstx1, dsty2 - dsty1); } return true; } return false; }
Example 5
Source File: DrawGlyphList.java From Bytecoder with Apache License 2.0 | 5 votes |
public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest, GlyphList gl) { int[] strbounds = gl.getBounds(); // Don't delete, bug 4895493 int num = gl.getNumGlyphs(); Region clip = sg2d.getCompClip(); int cx1 = clip.getLoX(); int cy1 = clip.getLoY(); int cx2 = clip.getHiX(); int cy2 = clip.getHiY(); for (int i = 0; i < num; i++) { gl.setGlyphIndex(i); int[] metrics = gl.getMetrics(); int gx1 = metrics[0]; int gy1 = metrics[1]; int w = metrics[2]; int gx2 = gx1 + w; int gy2 = gy1 + metrics[3]; int off = 0; if (gx1 < cx1) { off = cx1 - gx1; gx1 = cx1; } if (gy1 < cy1) { off += (cy1 - gy1) * w; gy1 = cy1; } if (gx2 > cx2) gx2 = cx2; if (gy2 > cy2) gy2 = cy2; if (gx2 > gx1 && gy2 > gy1) { byte[] alpha = gl.getGrayBits(); maskop.MaskFill(sg2d, dest, sg2d.composite, gx1, gy1, gx2 - gx1, gy2 - gy1, alpha, off, w); } } }
Example 6
Source File: GDIWindowSurfaceData.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, int dx, int dy) { CompositeType comptype = sg2d.imageComp; if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE && sg2d.clipState != sg2d.CLIP_SHAPE && (CompositeType.SrcOverNoEa.equals(comptype) || CompositeType.SrcNoEa.equals(comptype))) { x += sg2d.transX; y += sg2d.transY; int dstx1 = x + dx; int dsty1 = y + dy; int dstx2 = dstx1 + w; int dsty2 = dsty1 + h; Region clip = sg2d.getCompClip(); if (dstx1 < clip.getLoX()) dstx1 = clip.getLoX(); if (dsty1 < clip.getLoY()) dsty1 = clip.getLoY(); if (dstx2 > clip.getHiX()) dstx2 = clip.getHiX(); if (dsty2 > clip.getHiY()) dsty2 = clip.getHiY(); if (dstx1 < dstx2 && dsty1 < dsty2) { gdiPipe.devCopyArea(this, dstx1 - dx, dsty1 - dy, dx, dy, dstx2 - dstx1, dsty2 - dsty1); } return true; } return false; }
Example 7
Source File: DrawGlyphList.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest, GlyphList gl, int fromGlyph, int toGlyph) { Region clip = sg2d.getCompClip(); int cx1 = clip.getLoX(); int cy1 = clip.getLoY(); int cx2 = clip.getHiX(); int cy2 = clip.getHiY(); for (int i = fromGlyph; i < toGlyph; i++) { gl.setGlyphIndex(i); int metrics[] = gl.getMetrics(); int gx1 = metrics[0]; int gy1 = metrics[1]; int w = metrics[2]; int gx2 = gx1 + w; int gy2 = gy1 + metrics[3]; int off = 0; if (gx1 < cx1) { off = cx1 - gx1; gx1 = cx1; } if (gy1 < cy1) { off += (cy1 - gy1) * w; gy1 = cy1; } if (gx2 > cx2) gx2 = cx2; if (gy2 > cy2) gy2 = cy2; if (gx2 > gx1 && gy2 > gy1) { byte alpha[] = gl.getGrayBits(); maskop.MaskFill(sg2d, dest, sg2d.composite, gx1, gy1, gx2 - gx1, gy2 - gy1, alpha, off, w); } } }
Example 8
Source File: DrawGlyphList.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public void DrawGlyphList(SunGraphics2D sg2d, SurfaceData dest, GlyphList gl) { int strbounds[] = gl.getBounds(); // Don't delete, bug 4895493 int num = gl.getNumGlyphs(); Region clip = sg2d.getCompClip(); int cx1 = clip.getLoX(); int cy1 = clip.getLoY(); int cx2 = clip.getHiX(); int cy2 = clip.getHiY(); for (int i = 0; i < num; i++) { gl.setGlyphIndex(i); int metrics[] = gl.getMetrics(); int gx1 = metrics[0]; int gy1 = metrics[1]; int w = metrics[2]; int gx2 = gx1 + w; int gy2 = gy1 + metrics[3]; int off = 0; if (gx1 < cx1) { off = cx1 - gx1; gx1 = cx1; } if (gy1 < cy1) { off += (cy1 - gy1) * w; gy1 = cy1; } if (gx2 > cx2) gx2 = cx2; if (gy2 > cy2) gy2 = cy2; if (gx2 > gx1 && gy2 > gy1) { byte alpha[] = gl.getGrayBits(); maskop.MaskFill(sg2d, dest, sg2d.composite, gx1, gy1, gx2 - gx1, gy2 - gy1, alpha, off, w); } } }
Example 9
Source File: GeneralRenderer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public PixelWriterDrawHandler(SurfaceData sData, PixelWriter pw, Region clip, int strokeHint) { super(clip.getLoX(), clip.getLoY(), clip.getHiX(), clip.getHiY(), strokeHint); this.sData = sData; this.pw = pw; this.clip = clip; }
Example 10
Source File: GeneralRenderer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void doDrawRect(PixelWriter pw, SunGraphics2D sg2d, SurfaceData sData, int x, int y, int w, int h) { if (w < 0 || h < 0) { return; } int x2 = Region.dimAdd(Region.dimAdd(x, w), 1); int y2 = Region.dimAdd(Region.dimAdd(y, h), 1); Region r = sg2d.getCompClip().getBoundsIntersectionXYXY(x, y, x2, y2); if (r.isEmpty()) { return; } int cx1 = r.getLoX(); int cy1 = r.getLoY(); int cx2 = r.getHiX(); int cy2 = r.getHiY(); if (w < 2 || h < 2) { doSetRect(sData, pw, cx1, cy1, cx2, cy2); return; } if (cy1 == y) { doSetRect(sData, pw, cx1, cy1, cx2, cy1+1); } if (cx1 == x) { doSetRect(sData, pw, cx1, cy1+1, cx1+1, cy2-1); } if (cx2 == x2) { doSetRect(sData, pw, cx2-1, cy1+1, cx2, cy2-1); } if (cy2 == y2) { doSetRect(sData, pw, cx1, cy2-1, cx2, cy2); } }
Example 11
Source File: DrawGlyphListAA.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData dest, GlyphList gl) { gl.getBounds(); // Don't delete, bug 4895493 int num = gl.getNumGlyphs(); Region clip = sg2d.getCompClip(); int cx1 = clip.getLoX(); int cy1 = clip.getLoY(); int cx2 = clip.getHiX(); int cy2 = clip.getHiY(); for (int i = 0; i < num; i++) { gl.setGlyphIndex(i); int metrics[] = gl.getMetrics(); int gx1 = metrics[0]; int gy1 = metrics[1]; int w = metrics[2]; int gx2 = gx1 + w; int gy2 = gy1 + metrics[3]; int off = 0; if (gx1 < cx1) { off = cx1 - gx1; gx1 = cx1; } if (gy1 < cy1) { off += (cy1 - gy1) * w; gy1 = cy1; } if (gx2 > cx2) gx2 = cx2; if (gy2 > cy2) gy2 = cy2; if (gx2 > gx1 && gy2 > gy1) { byte alpha[] = gl.getGrayBits(); maskop.MaskFill(sg2d, dest, sg2d.composite, gx1, gy1, gx2 - gx1, gy2 - gy1, alpha, off, w); } } }
Example 12
Source File: DrawGlyphListAA.java From Bytecoder with Apache License 2.0 | 5 votes |
public void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData dest, GlyphList gl) { gl.getBounds(); // Don't delete, bug 4895493 int num = gl.getNumGlyphs(); Region clip = sg2d.getCompClip(); int cx1 = clip.getLoX(); int cy1 = clip.getLoY(); int cx2 = clip.getHiX(); int cy2 = clip.getHiY(); for (int i = 0; i < num; i++) { gl.setGlyphIndex(i); int[] metrics = gl.getMetrics(); int gx1 = metrics[0]; int gy1 = metrics[1]; int w = metrics[2]; int gx2 = gx1 + w; int gy2 = gy1 + metrics[3]; int off = 0; if (gx1 < cx1) { off = cx1 - gx1; gx1 = cx1; } if (gy1 < cy1) { off += (cy1 - gy1) * w; gy1 = cy1; } if (gx2 > cx2) gx2 = cx2; if (gy2 > cy2) gy2 = cy2; if (gx2 > gx1 && gy2 > gy1) { byte[] alpha = gl.getGrayBits(); maskop.MaskFill(sg2d, dest, sg2d.composite, gx1, gy1, gx2 - gx1, gy2 - gy1, alpha, off, w); } } }
Example 13
Source File: GeneralRenderer.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public PixelWriterDrawHandler(SurfaceData sData, PixelWriter pw, Region clip, int strokeHint) { super(clip.getLoX(), clip.getLoY(), clip.getHiX(), clip.getHiY(), strokeHint); this.sData = sData; this.pw = pw; this.clip = clip; }
Example 14
Source File: DrawGlyphListColor.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public void DrawGlyphListColor(SunGraphics2D sg2d, SurfaceData dest, GlyphList gl, int fromGlyph, int toGlyph) { Region clip = sg2d.getCompClip(); int cx1 = clip.getLoX(); int cy1 = clip.getLoY(); int cx2 = clip.getHiX(); int cy2 = clip.getHiY(); for (int i = fromGlyph; i < toGlyph; i++) { gl.setGlyphIndex(i); int metrics[] = gl.getMetrics(); int x = metrics[0]; int y = metrics[1]; int w = metrics[2]; int h = metrics[3]; int gx1 = x; int gy1 = y; int gx2 = x + w; int gy2 = y + h; if (gx1 < cx1) gx1 = cx1; if (gy1 < cy1) gy1 = cy1; if (gx2 > cx2) gx2 = cx2; if (gy2 > cy2) gy2 = cy2; if (gx2 > gx1 && gy2 > gy1) { blit.Blit(gl.getColorGlyphData(), dest, AlphaComposite.SrcOver, clip, gx1 - x, gy1 - y, gx1, gy1, gx2 - gx1, gy2 - gy1); } } }
Example 15
Source File: DrawGlyphListAA.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData dest, GlyphList gl, int fromGlyph, int toGlyph) { Region clip = sg2d.getCompClip(); int cx1 = clip.getLoX(); int cy1 = clip.getLoY(); int cx2 = clip.getHiX(); int cy2 = clip.getHiY(); for (int i = fromGlyph; i < toGlyph; i++) { gl.setGlyphIndex(i); int metrics[] = gl.getMetrics(); int gx1 = metrics[0]; int gy1 = metrics[1]; int w = metrics[2]; int gx2 = gx1 + w; int gy2 = gy1 + metrics[3]; int off = 0; if (gx1 < cx1) { off = cx1 - gx1; gx1 = cx1; } if (gy1 < cy1) { off += (cy1 - gy1) * w; gy1 = cy1; } if (gx2 > cx2) gx2 = cx2; if (gy2 > cy2) gy2 = cy2; if (gx2 > gx1 && gy2 > gy1) { byte alpha[] = gl.getGrayBits(); maskop.MaskFill(sg2d, dest, sg2d.composite, gx1, gy1, gx2 - gx1, gy2 - gy1, alpha, off, w); } } }
Example 16
Source File: GDIWindowSurfaceData.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, int dx, int dy) { CompositeType comptype = sg2d.imageComp; if (sg2d.transformState < sg2d.TRANSFORM_TRANSLATESCALE && sg2d.clipState != sg2d.CLIP_SHAPE && (CompositeType.SrcOverNoEa.equals(comptype) || CompositeType.SrcNoEa.equals(comptype))) { x += sg2d.transX; y += sg2d.transY; int dstx1 = x + dx; int dsty1 = y + dy; int dstx2 = dstx1 + w; int dsty2 = dsty1 + h; Region clip = sg2d.getCompClip(); if (dstx1 < clip.getLoX()) dstx1 = clip.getLoX(); if (dsty1 < clip.getLoY()) dsty1 = clip.getLoY(); if (dstx2 > clip.getHiX()) dstx2 = clip.getHiX(); if (dsty2 > clip.getHiY()) dsty2 = clip.getHiY(); if (dstx1 < dstx2 && dsty1 < dsty2) { gdiPipe.devCopyArea(this, dstx1 - dx, dsty1 - dy, dx, dy, dstx2 - dstx1, dsty2 - dsty1); } return true; } return false; }
Example 17
Source File: SunGraphics2D.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Returns a rectangle in image coordinates that may be required * in order to draw the given image into the given clipping region * through a pair of AffineTransforms. In addition, horizontal and * vertical padding factors for antialising and interpolation may * be used. */ private static Rectangle getImageRegion(RenderedImage img, Region compClip, AffineTransform transform, AffineTransform xform, int padX, int padY) { Rectangle imageRect = new Rectangle(img.getMinX(), img.getMinY(), img.getWidth(), img.getHeight()); Rectangle result = null; try { double p[] = new double[8]; p[0] = p[2] = compClip.getLoX(); p[4] = p[6] = compClip.getHiX(); p[1] = p[5] = compClip.getLoY(); p[3] = p[7] = compClip.getHiY(); // Inverse transform the output bounding rect transform.inverseTransform(p, 0, p, 0, 4); xform.inverseTransform(p, 0, p, 0, 4); // Determine a bounding box for the inverse transformed region double x0,x1,y0,y1; x0 = x1 = p[0]; y0 = y1 = p[1]; for (int i = 2; i < 8; ) { double pt = p[i++]; if (pt < x0) { x0 = pt; } else if (pt > x1) { x1 = pt; } pt = p[i++]; if (pt < y0) { y0 = pt; } else if (pt > y1) { y1 = pt; } } // This is padding for anti-aliasing and such. It may // be more than is needed. int x = (int)x0 - padX; int w = (int)(x1 - x0 + 2*padX); int y = (int)y0 - padY; int h = (int)(y1 - y0 + 2*padY); Rectangle clipRect = new Rectangle(x,y,w,h); result = clipRect.intersection(imageRect); } catch (NoninvertibleTransformException nte) { // Worst case bounds are the bounds of the image. result = imageRect; } return result; }
Example 18
Source File: SunGraphics2D.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Returns a rectangle in image coordinates that may be required * in order to draw the given image into the given clipping region * through a pair of AffineTransforms. In addition, horizontal and * vertical padding factors for antialising and interpolation may * be used. */ private static Rectangle getImageRegion(RenderedImage img, Region compClip, AffineTransform transform, AffineTransform xform, int padX, int padY) { Rectangle imageRect = new Rectangle(img.getMinX(), img.getMinY(), img.getWidth(), img.getHeight()); Rectangle result = null; try { double p[] = new double[8]; p[0] = p[2] = compClip.getLoX(); p[4] = p[6] = compClip.getHiX(); p[1] = p[5] = compClip.getLoY(); p[3] = p[7] = compClip.getHiY(); // Inverse transform the output bounding rect transform.inverseTransform(p, 0, p, 0, 4); xform.inverseTransform(p, 0, p, 0, 4); // Determine a bounding box for the inverse transformed region double x0,x1,y0,y1; x0 = x1 = p[0]; y0 = y1 = p[1]; for (int i = 2; i < 8; ) { double pt = p[i++]; if (pt < x0) { x0 = pt; } else if (pt > x1) { x1 = pt; } pt = p[i++]; if (pt < y0) { y0 = pt; } else if (pt > y1) { y1 = pt; } } // This is padding for anti-aliasing and such. It may // be more than is needed. int x = (int)x0 - padX; int w = (int)(x1 - x0 + 2*padX); int y = (int)y0 - padY; int h = (int)(y1 - y0 + 2*padY); Rectangle clipRect = new Rectangle(x,y,w,h); result = clipRect.intersection(imageRect); } catch (NoninvertibleTransformException nte) { // Worst case bounds are the bounds of the image. result = imageRect; } return result; }
Example 19
Source File: SunGraphics2D.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Returns a rectangle in image coordinates that may be required * in order to draw the given image into the given clipping region * through a pair of AffineTransforms. In addition, horizontal and * vertical padding factors for antialising and interpolation may * be used. */ private static Rectangle getImageRegion(RenderedImage img, Region compClip, AffineTransform transform, AffineTransform xform, int padX, int padY) { Rectangle imageRect = new Rectangle(img.getMinX(), img.getMinY(), img.getWidth(), img.getHeight()); Rectangle result = null; try { double p[] = new double[8]; p[0] = p[2] = compClip.getLoX(); p[4] = p[6] = compClip.getHiX(); p[1] = p[5] = compClip.getLoY(); p[3] = p[7] = compClip.getHiY(); // Inverse transform the output bounding rect transform.inverseTransform(p, 0, p, 0, 4); xform.inverseTransform(p, 0, p, 0, 4); // Determine a bounding box for the inverse transformed region double x0,x1,y0,y1; x0 = x1 = p[0]; y0 = y1 = p[1]; for (int i = 2; i < 8; ) { double pt = p[i++]; if (pt < x0) { x0 = pt; } else if (pt > x1) { x1 = pt; } pt = p[i++]; if (pt < y0) { y0 = pt; } else if (pt > y1) { y1 = pt; } } // This is padding for anti-aliasing and such. It may // be more than is needed. int x = (int)x0 - padX; int w = (int)(x1 - x0 + 2*padX); int y = (int)y0 - padY; int h = (int)(y1 - y0 + 2*padY); Rectangle clipRect = new Rectangle(x,y,w,h); result = clipRect.intersection(imageRect); } catch (NoninvertibleTransformException nte) { // Worst case bounds are the bounds of the image. result = imageRect; } return result; }
Example 20
Source File: SunGraphics2D.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Returns a rectangle in image coordinates that may be required * in order to draw the given image into the given clipping region * through a pair of AffineTransforms. In addition, horizontal and * vertical padding factors for antialising and interpolation may * be used. */ private static Rectangle getImageRegion(RenderedImage img, Region compClip, AffineTransform transform, AffineTransform xform, int padX, int padY) { Rectangle imageRect = new Rectangle(img.getMinX(), img.getMinY(), img.getWidth(), img.getHeight()); Rectangle result = null; try { double p[] = new double[8]; p[0] = p[2] = compClip.getLoX(); p[4] = p[6] = compClip.getHiX(); p[1] = p[5] = compClip.getLoY(); p[3] = p[7] = compClip.getHiY(); // Inverse transform the output bounding rect transform.inverseTransform(p, 0, p, 0, 4); xform.inverseTransform(p, 0, p, 0, 4); // Determine a bounding box for the inverse transformed region double x0,x1,y0,y1; x0 = x1 = p[0]; y0 = y1 = p[1]; for (int i = 2; i < 8; ) { double pt = p[i++]; if (pt < x0) { x0 = pt; } else if (pt > x1) { x1 = pt; } pt = p[i++]; if (pt < y0) { y0 = pt; } else if (pt > y1) { y1 = pt; } } // This is padding for anti-aliasing and such. It may // be more than is needed. int x = (int)x0 - padX; int w = (int)(x1 - x0 + 2*padX); int y = (int)y0 - padY; int h = (int)(y1 - y0 + 2*padY); Rectangle clipRect = new Rectangle(x,y,w,h); result = clipRect.intersection(imageRect); } catch (NoninvertibleTransformException nte) { // Worst case bounds are the bounds of the image. result = imageRect; } return result; }