Permalink
Browse files

GraphicsUtils.getAlphaImage() returns black image for transparent inp…

…ut with bitmask alpha.
  • Loading branch information...
eseifert committed Aug 19, 2017
1 parent 6979aa7 commit dc319e9e9c5c242871b13880cdb8c3b8be8ee938
Showing with 19 additions and 0 deletions.
  1. +19 −0 src/test/java/de/erichseifert/vectorgraphics2d/util/GraphicsUtilsTest.java
@@ -34,12 +34,15 @@
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.Toolkit;
import java.awt.Transparency;
import java.awt.geom.Arc2D;
import java.awt.geom.CubicCurve2D;
import java.awt.geom.Ellipse2D;
@@ -435,4 +438,20 @@ public void getAlphaImageReturnsBlackImageForTransparentInput() {
g.fillRect(0, 0, expected.getWidth(), expected.getHeight());
assertBufferedImageContentEquals(expected, result);
}
@Test
public void getAlphaImageReturnsBlackImageForTransparentInputWithBitmaskAlpha() {
GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = environment.getDefaultScreenDevice();
GraphicsConfiguration config = device.getDefaultConfiguration();
BufferedImage image = config.createCompatibleImage(3, 3, Transparency.BITMASK);
BufferedImage result = GraphicsUtils.getAlphaImage(image);
BufferedImage expected = new BufferedImage(3, 3, BufferedImage.TYPE_BYTE_GRAY);
Graphics g = expected.getGraphics();
g.setColor(Color.BLACK);
g.fillRect(0, 0, expected.getWidth(), expected.getHeight());
assertBufferedImageContentEquals(expected, result);
}
}

0 comments on commit dc319e9

Please sign in to comment.