java.awt.AlphaComposite Java Examples
The following examples show how to use
java.awt.AlphaComposite.
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: ImgUtils.java From TranskribusCore with GNU General Public License v3.0 | 7 votes |
public static File killBorder(BufferedImage baseImage, Polygon p, String outPng) throws IOException { // Creates a background BufferedImage with an Alpha layer so that AlphaCompositing works final int height = baseImage.getHeight(); final int width = baseImage.getWidth(); BufferedImage bg = new BufferedImage (width, height, BufferedImage.TYPE_INT_ARGB); // Sets AlphaComposite to type SRC_OUT with a transparency of 100% // Convert BufferedImage to G2D. Effects applied to G2D are applied to the original BufferedImage automatically. Graphics2D g2d = bg.createGraphics(); //create Area with dimension of the image to be cropped Area wholeImageArea = new Area(new Rectangle(width, height)); //create Area from given polygon Area psArea = new Area(p); //invert the printspace area wholeImageArea.subtract(psArea); // Covers the whole image to provide a layer to be cropped, revealing the imported image underneath g2d.fill(wholeImageArea); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OUT, 1.0f)); // Draws the imported image into the background BufferedImage (bg). g2d.drawImage(baseImage, 0, 0, null); // Writes the image to a PNG if(!outPng.endsWith(".png")){ outPng += ".png"; } File out = new File(outPng); if(!ImageIO.write(bg, "png", out)){ //should not happen with png throw new IOException("No appropriate writer was found!"); } return out; }
Example #2
Source File: BusySpinnerPanel.java From azure-devops-intellij with MIT License | 6 votes |
@Override public void paint(Graphics g) { super.paint(g); // get width and height final int width = getWidth(); final int height = getHeight(); // Draw 12 lines around the center point in a circle int lineLength = Math.min(width, height) / 5; int lineWidth = lineLength / 4; int cx = width / 2; int cy = height / 2; Graphics2D g2 = (Graphics2D) g.create(); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setStroke(new BasicStroke(lineWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); g2.setPaint(JBColor.black); g2.rotate(Math.PI * rotationAngle / 180, cx, cy); for (int i = 0; i < 12; i++) { g2.drawLine(cx + lineLength, cy, cx + lineLength * 2, cy); g2.rotate(-Math.PI / 6, cx, cy); g2.setComposite(AlphaComposite.getInstance( AlphaComposite.SRC_OVER, ((11 - i) / 12.0f) * (2.0f / 3.0f))); } g2.dispose(); }
Example #3
Source File: TranslucentButton.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void paint(Graphics g) { // Create an image for the button graphics if necessary if (buttonImage == null || buttonImage.getWidth() != getWidth() || buttonImage.getHeight() != getHeight()) { buttonImage = getGraphicsConfiguration(). createCompatibleImage(getWidth(), getHeight()); } Graphics gButton = buttonImage.getGraphics(); gButton.setClip(g.getClip()); // Have the superclass render the button for us super.paint(gButton); // Make the graphics object sent to this paint() method translucent Graphics2D g2d = (Graphics2D)g; AlphaComposite newComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .5f); g2d.setComposite(newComposite); // Copy the button's image to the destination graphics, translucently g2d.drawImage(buttonImage, 0, 0, null); }
Example #4
Source File: UnmanagedDrawImagePerformance.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
private static long test(Image bi, Image vi, AffineTransform atfm) { final Polygon p = new Polygon(); p.addPoint(0, 0); p.addPoint(SIZE, 0); p.addPoint(0, SIZE); p.addPoint(SIZE, SIZE); p.addPoint(0, 0); Graphics2D g2d = (Graphics2D) vi.getGraphics(); g2d.clip(p); g2d.transform(atfm); g2d.setComposite(AlphaComposite.SrcOver); final long start = System.nanoTime(); g2d.drawImage(bi, 0, 0, null); final long time = System.nanoTime() - start; g2d.dispose(); return time; }
Example #5
Source File: IncorrectClipSurface2SW.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private static void draw(Shape clip, Shape to, Image vi, BufferedImage bi, int scale) { Graphics2D big = bi.createGraphics(); big.setComposite(AlphaComposite.Src); big.setClip(clip); Rectangle toBounds = to.getBounds(); int x1 = toBounds.x; int y1 = toBounds.y; int x2 = x1 + toBounds.width; int y2 = y1 + toBounds.height; big.drawImage(vi, x1, y1, x2, y2, 0, 0, toBounds.width / scale, toBounds.height / scale, null); big.dispose(); vi.flush(); }
Example #6
Source File: Plot.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Draws the background image (if there is one) aligned within the * specified area. * * @param g2 the graphics device. * @param area the area. * * @see #getBackgroundImage() * @see #getBackgroundImageAlignment() * @see #getBackgroundImageAlpha() */ public void drawBackgroundImage(Graphics2D g2, Rectangle2D area) { if (this.backgroundImage == null) { return; // nothing to do } Composite savedComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, this.backgroundImageAlpha)); Rectangle2D dest = new Rectangle2D.Double(0.0, 0.0, this.backgroundImage.getWidth(null), this.backgroundImage.getHeight(null)); Align.align(dest, area, this.backgroundImageAlignment); Shape savedClip = g2.getClip(); g2.clip(area); g2.drawImage(this.backgroundImage, (int) dest.getX(), (int) dest.getY(), (int) dest.getWidth() + 1, (int) dest.getHeight() + 1, null); g2.setClip(savedClip); g2.setComposite(savedComposite); }
Example #7
Source File: PdfGraphics2D.java From itext2 with GNU Lesser General Public License v3.0 | 6 votes |
/** * Method contributed by Alexej Suchov * @see Graphics2D#setComposite(Composite) */ public void setComposite(Composite comp) { if (comp instanceof AlphaComposite) { AlphaComposite composite = (AlphaComposite) comp; if (composite.getRule() == 3) { alpha = composite.getAlpha(); this.composite = composite; if (realPaint != null && (realPaint instanceof Color)) { Color c = (Color) realPaint; paint = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (c.getAlpha() * alpha)); } return; } } this.composite = comp; alpha = 1.0F; }
Example #8
Source File: PeekMetrics.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Record information about drawing done * with the supplied <code>Composite</code>. */ private void checkAlpha(Composite composite) { if (composite instanceof AlphaComposite) { AlphaComposite alphaComposite = (AlphaComposite) composite; float alpha = alphaComposite.getAlpha(); int rule = alphaComposite.getRule(); if (alpha != 1.0 || (rule != AlphaComposite.SRC && rule != AlphaComposite.SRC_OVER)) { mHasCompositing = true; } } else { mHasCompositing = true; } }
Example #9
Source File: Treeline.java From TrakEM2 with GNU General Public License v3.0 | 6 votes |
@Override public void paintData(final Graphics2D g, final Rectangle srcRect, final Tree<Float> tree, final AffineTransform to_screen, final Color cc, final Layer active_layer) { if (null == this.parent) return; // doing it here for less total cost if (0 == this.r && 0 == parent.getData()) return; // Two transformations, but it's only 4 points each and it's necessary //final Polygon segment = getSegment(); //if (!tree.at.createTransformedShape(segment).intersects(srcRect)) return Node.FALSE; //final Shape shape = to_screen.createTransformedShape(segment); final Shape shape = to_screen.createTransformedShape(getSegment()); final Composite c = g.getComposite(); final float alpha = tree.getAlpha(); g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha > 0.4f ? 0.4f : alpha)); g.setColor(cc); g.fill(shape); g.setComposite(c); g.draw(shape); // in Tree's composite mode (such as an alpha) }
Example #10
Source File: BufferedContext.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
private void setComposite(Composite comp, int flags) { // assert rq.lock.isHeldByCurrentThread(); if (comp instanceof AlphaComposite) { AlphaComposite ac = (AlphaComposite)comp; rq.ensureCapacity(16); buf.putInt(SET_ALPHA_COMPOSITE); buf.putInt(ac.getRule()); buf.putFloat(ac.getAlpha()); buf.putInt(flags); } else if (comp instanceof XORComposite) { int xorPixel = ((XORComposite)comp).getXorPixel(); rq.ensureCapacity(8); buf.putInt(SET_XOR_COMPOSITE); buf.putInt(xorPixel); } else { throw new InternalError("not yet implemented"); } }
Example #11
Source File: HighlightedButton.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Creates a new instance of HighlightedButton */ public HighlightedButton(String label) { super(label); // Get the Graphics for the image Graphics2D g2d = highlight.createGraphics(); // Erase the image with a transparent background g2d.setComposite(AlphaComposite.Clear); g2d.fillRect(0, 0, HIGHLIGHT_SIZE, HIGHLIGHT_SIZE); g2d.setComposite(AlphaComposite.SrcOver); // Draw the highlight Point2D center = new Point2D.Float((float)HIGHLIGHT_SIZE / 2.0f, (float)HIGHLIGHT_SIZE / 2.0f); float radius = (float)HIGHLIGHT_SIZE / 2.0f; float[] dist = {0.0f, .85f}; Color[] colors = {Color.white, new Color(255, 255, 255, 0)}; RadialGradientPaint paint = new RadialGradientPaint(center, radius, dist, colors); g2d.setPaint(paint); g2d.fillOval(0, 0, HIGHLIGHT_SIZE, HIGHLIGHT_SIZE); g2d.dispose(); }
Example #12
Source File: DefaultPolarItemRenderer.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Creates a new instance of DefaultPolarItemRenderer */ public DefaultPolarItemRenderer() { this.seriesFilled = new BooleanList(); this.drawOutlineWhenFilled = true; this.fillComposite = AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.3f); this.useFillPaint = false; // use item paint for fills by default this.legendLine = new Line2D.Double(-7.0, 0.0, 7.0, 0.0); this.shapesVisible = true; this.connectFirstAndLastPoint = true; this.toolTipGeneratorList = new ObjectList(); this.urlGenerator = null; this.legendItemToolTipGenerator = null; this.legendItemURLGenerator = null; }
Example #13
Source File: ImageInfoReader.java From WorldGrower with GNU General Public License v3.0 | 6 votes |
private void createAnimation(ImageIds animationImageId, ImageIds imageId, int numberOfFrames) { List<Image> images = new ArrayList<>(); for(int i=0; i<numberOfFrames; i++) { BufferedImage newImage = new BufferedImage(48, 48, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = (Graphics2D) newImage.getGraphics(); Image image = idToImages.get(imageId).get(0); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f * i)); g2.drawImage(image, 0, 0, null); g2.dispose(); images.add(newImage); } idToImages.put(animationImageId, images); }
Example #14
Source File: Plot.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Draws the background image (if there is one) aligned within the * specified area. * * @param g2 the graphics device. * @param area the area. * * @see #getBackgroundImage() * @see #getBackgroundImageAlignment() * @see #getBackgroundImageAlpha() */ public void drawBackgroundImage(Graphics2D g2, Rectangle2D area) { if (this.backgroundImage == null) { return; // nothing to do } Composite savedComposite = g2.getComposite(); g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, this.backgroundImageAlpha)); Rectangle2D dest = new Rectangle2D.Double(0.0, 0.0, this.backgroundImage.getWidth(null), this.backgroundImage.getHeight(null)); Align.align(dest, area, this.backgroundImageAlignment); Shape savedClip = g2.getClip(); g2.clip(area); g2.drawImage(this.backgroundImage, (int) dest.getX(), (int) dest.getY(), (int) dest.getWidth() + 1, (int) dest.getHeight() + 1, null); g2.setClip(savedClip); g2.setComposite(savedComposite); }
Example #15
Source File: ImageBorderWizard.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height ) { g.setColor(getColor(colorA)); Graphics2D g2d = (Graphics2D)g; g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY); g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, get(opacity) / 255.0f)); RoundRectangle2D rr = new RoundRectangle2D.Float(x, y, width - 1, height - 1, get(arcWidth), get(arcHeight)); g2d.setPaint(new GradientPaint(x + width / 2, y, getColor(colorA), x + width / 2, y + height, getColor(colorB))); g2d.fill(rr); if(get(thickness) > 0) { g2d.setPaint(new GradientPaint(x + width / 2, y, getColor(colorC), x + width / 2, y + height, getColor(colorD))); g2d.setStroke(new BasicStroke(get(thickness))); g2d.draw(rr); } }
Example #16
Source File: PeekMetrics.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Record information about drawing done * with the supplied <code>Composite</code>. */ private void checkAlpha(Composite composite) { if (composite instanceof AlphaComposite) { AlphaComposite alphaComposite = (AlphaComposite) composite; float alpha = alphaComposite.getAlpha(); int rule = alphaComposite.getRule(); if (alpha != 1.0 || (rule != AlphaComposite.SRC && rule != AlphaComposite.SRC_OVER)) { mHasCompositing = true; } } else { mHasCompositing = true; } }
Example #17
Source File: ImageTests.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public void modifyTest(TestEnvironment env) { int size = env.getIntValue(sizeList); Image src = tsit.getImage(env, size, size); Graphics g = src.getGraphics(); if (hasGraphics2D) { ((Graphics2D) g).setComposite(AlphaComposite.Src); } if (size == 1) { g.setColor(colorsets[transparency][4]); g.fillRect(0, 0, 1, 1); } else { int mid = size/2; g.setColor(colorsets[transparency][0]); g.fillRect(0, 0, mid, mid); g.setColor(colorsets[transparency][1]); g.fillRect(mid, 0, size-mid, mid); g.setColor(colorsets[transparency][2]); g.fillRect(0, mid, mid, size-mid); g.setColor(colorsets[transparency][3]); g.fillRect(mid, mid, size-mid, size-mid); } g.dispose(); env.setSrcImage(src); }
Example #18
Source File: RenderTests.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private TexturePaint makeTexturePaint(int size, boolean alpha) { int s2 = size / 2; int type = alpha ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB; BufferedImage img = new BufferedImage(size, size, type); Color[] colors = makeGradientColors(4, alpha); Graphics2D g2d = img.createGraphics(); g2d.setComposite(AlphaComposite.Src); g2d.setColor(colors[0]); g2d.fillRect(0, 0, s2, s2); g2d.setColor(colors[1]); g2d.fillRect(s2, 0, s2, s2); g2d.setColor(colors[3]); g2d.fillRect(0, s2, s2, s2); g2d.setColor(colors[2]); g2d.fillRect(s2, s2, s2, s2); g2d.dispose(); Rectangle2D bounds = new Rectangle2D.Float(0, 0, size, size); return new TexturePaint(img, bounds); }
Example #19
Source File: CommonGFX.java From open-ig with GNU Lesser General Public License v3.0 | 6 votes |
/** * Initialize the common resources. * @param rl the resource locator * @return this */ public CommonGFX load(ResourceLocator rl) { GFXLoader.loadResources(this, rl); int[] disabled = { 0xFF000000, 0xFF000000, 0, 0, 0xFF000000, 0, 0, 0, 0 }; disabledPattern = new BufferedImage(3, 3, BufferedImage.TYPE_INT_ARGB); disabledPattern.setRGB(0, 0, 3, 3, disabled, 0, 3); achievementGrayed = new BufferedImage(achievement.getWidth(), achievement.getHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = achievementGrayed.createGraphics(); g2.drawImage(achievement, 0, 0, null); g2.setComposite(AlphaComposite.SrcOver.derive(0.5f)); g2.setColor(Color.BLACK); g2.fillRect(0, 0, achievement.getWidth(), achievement.getHeight()); g2.dispose(); mediumButton = new GenericMediumButton("/hu/openig/gfx/button_medium.png"); mediumButtonPressed = new GenericMediumButton("/hu/openig/gfx/button_medium_pressed.png"); return this; }
Example #20
Source File: UnmanagedDrawImagePerformance.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static long test(Image bi, Image vi, AffineTransform atfm) { final Polygon p = new Polygon(); p.addPoint(0, 0); p.addPoint(SIZE, 0); p.addPoint(0, SIZE); p.addPoint(SIZE, SIZE); p.addPoint(0, 0); Graphics2D g2d = (Graphics2D) vi.getGraphics(); g2d.clip(p); g2d.transform(atfm); g2d.setComposite(AlphaComposite.SrcOver); final long start = System.nanoTime(); g2d.drawImage(bi, 0, 0, null); final long time = System.nanoTime() - start; g2d.dispose(); return time; }
Example #21
Source File: BlendComposite.java From gcs with Mozilla Public License 2.0 | 6 votes |
/** * Creates a blend composite * * @param blendMode Desired blend mode * @param constantAlpha Constant alpha, must be in the inclusive range * [0.0...1.0] or it will be clipped. * @return a blend composite. */ public static Composite getInstance(BlendMode blendMode, float constantAlpha) { if (constantAlpha < 0) { LOG.warn("using 0 instead of incorrect Alpha " + constantAlpha); constantAlpha = 0; } else if (constantAlpha > 1) { LOG.warn("using 1 instead of incorrect Alpha " + constantAlpha); constantAlpha = 1; } if (blendMode == BlendMode.NORMAL) { return AlphaComposite.getInstance(AlphaComposite.SRC_OVER, constantAlpha); } else { return new BlendComposite(blendMode, constantAlpha); } }
Example #22
Source File: DropShadowDemo.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 6 votes |
public static BufferedImage createDropShadow(BufferedImage image, int size) { BufferedImage shadow = new BufferedImage( image.getWidth() + 4 * size, image.getHeight() + 4 * size, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = shadow.createGraphics(); g2.drawImage(image, size * 2, size * 2, null); g2.setComposite(AlphaComposite.SrcIn); g2.setColor(Color.BLACK); g2.fillRect(0, 0, shadow.getWidth(), shadow.getHeight()); g2.dispose(); shadow = getGaussianBlurFilter(size, true).filter(shadow, null); shadow = getGaussianBlurFilter(size, false).filter(shadow, null); return shadow; }
Example #23
Source File: WorldPanel.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
private void drawWorldObject(Graphics g, WorldObject worldObject, LookDirection lookDirection, Image image, int x, int y) { boolean isIllusion = worldObject.hasProperty(Constants.ILLUSION_CREATOR_ID); boolean isTransparant = isIllusion && playerCharacter.getProperty(Constants.KNOWLEDGE_MAP).hasProperty(worldObject, Constants.ILLUSION_CREATOR_ID); Composite originalComposite = null; Graphics2D graphics2d = (Graphics2D)g; if (isTransparant) { originalComposite = graphics2d.getComposite(); graphics2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f)); } drawWorldObjectInPixels(g, worldObject, lookDirection, image, x, y, 0, 0, true); if (isTransparant) { graphics2d.setComposite(originalComposite); } }
Example #24
Source File: OpaqueImageToSurfaceBlitTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gd.getDefaultConfiguration(); VolatileImage vi = gc.createCompatibleVolatileImage(16, 16); vi.validate(gc); BufferedImage bi = new BufferedImage(2, 2, BufferedImage.TYPE_INT_RGB); int data[] = ((DataBufferInt)bi.getRaster().getDataBuffer()).getData(); data[0] = 0x0000007f; data[1] = 0x0000007f; data[2] = 0xff00007f; data[3] = 0xff00007f; Graphics2D g = vi.createGraphics(); g.setComposite(AlphaComposite.SrcOver.derive(0.999f)); g.drawImage(bi, 0, 0, null); bi = vi.getSnapshot(); if (bi.getRGB(0, 0) != bi.getRGB(1, 1)) { throw new RuntimeException("Test FAILED: color at 0x0 ="+ Integer.toHexString(bi.getRGB(0, 0))+" differs from 1x1 ="+ Integer.toHexString(bi.getRGB(1,1))); } System.out.println("Test PASSED."); }
Example #25
Source File: Reflection.java From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void applyAlphaMask(BufferedImage buffer, BufferedImage alphaMask, int avatarHeight) { Graphics2D g2 = buffer.createGraphics(); g2.setComposite(AlphaComposite.DstOut); g2.drawImage(alphaMask, null, 0, avatarHeight); g2.dispose(); }
Example #26
Source File: VectorImageTest.java From pumpernickel with MIT License | 5 votes |
/** * This tests clipping different Graphics2Ds, drawing arcs, a SrcOut * composite to clear pixels. */ public void testContext1() throws Exception { RenderTest t = new RenderTest() { @Override public void paint(Graphics2D g) { g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setStroke(new BasicStroke(15)); g.clipRect(20, 20, 160, 160); g.setColor(Color.cyan); g.fillRect(0, 0, 200, 200); Graphics2D g2 = (Graphics2D) g.create(40, 40, 100, 100); g2.setColor(Color.pink); g2.drawArc(20, 20, 120, 120, 0, 190); Graphics2D g3 = (Graphics2D) g.create(60, 0, 100, 100); g3.setComposite(AlphaComposite.SrcOut); g3.setColor(Color.magenta); g3.drawArc(10, 10, 120, 120, 180, 340); } }; t.test(); }
Example #27
Source File: SunVolatileImage.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public BufferedImage getSnapshot() { BufferedImage bi = getBackupImage(); Graphics2D g = bi.createGraphics(); g.setComposite(AlphaComposite.Src); g.drawImage(this, 0, 0, null); g.dispose(); return bi; }
Example #28
Source File: SunCompositeContext.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public SunCompositeContext(AlphaComposite ac, ColorModel s, ColorModel d) { if (s == null) { throw new NullPointerException("Source color model cannot be null"); } if (d == null) { throw new NullPointerException("Destination color model cannot be null"); } srcCM = s; dstCM = d; this.composite = ac; this.comptype = CompositeType.forAlphaComposite(ac); }
Example #29
Source File: IncorrectUnmanagedImageSourceOffset.java From hottub with GNU General Public License v2.0 | 5 votes |
private static void fill(final Image image) { final Graphics2D graphics = (Graphics2D) image.getGraphics(); graphics.setComposite(AlphaComposite.Src); for (int i = 0; i < image.getHeight(null); ++i) { graphics.setColor(new Color(i, 0, 0)); graphics.fillRect(0, i, image.getWidth(null), 1); } graphics.dispose(); }
Example #30
Source File: SunCompositeContext.java From Bytecoder with Apache License 2.0 | 5 votes |
public SunCompositeContext(AlphaComposite ac, ColorModel s, ColorModel d) { if (s == null) { throw new NullPointerException("Source color model cannot be null"); } if (d == null) { throw new NullPointerException("Destination color model cannot be null"); } srcCM = s; dstCM = d; this.composite = ac; this.comptype = CompositeType.forAlphaComposite(ac); }