/** * Returns {@code true} if the {@linkplain #image} is {@linkplain Transparency#TRANSLUCENT * translucent}. * * @see #forceBitmaskIndexColorModel */ public final boolean isTranslucent() { return image.getColorModel().getTransparency() == Transparency.TRANSLUCENT; }
public BufferedImage filter(BufferedImage pSource, BufferedImage pDestination) { if (pSource == null) { throw new NullPointerException("source image is null"); } if (pSource == pDestination) { throw new IllegalArgumentException("source image cannot be the same as the destination image"); } int borderX = kernel.getWidth() / 2; int borderY = kernel.getHeight() / 2; BufferedImage original = addBorder(pSource, borderX, borderY); // Workaround for what seems to be a Java2D bug: // ConvolveOp needs explicit destination image type for some "uncommon" // image types. However, TYPE_3BYTE_BGR is what javax.imageio.ImageIO // normally returns for color JPEGs... :-/ BufferedImage destination = pDestination; if (original.getType() == BufferedImage.TYPE_3BYTE_BGR) { destination = ImageUtil.createBuffered( pSource.getWidth(), pSource.getHeight(), pSource.getType(), pSource.getColorModel().getTransparency(), null ); } // Do the filtering (if destination is null, a new image will be created) destination = convolve.filter(original, destination); if (pSource != original) { // Remove the border destination = destination.getSubimage(borderX, borderY, pSource.getWidth(), pSource.getHeight()); } return destination; }
this.subsampleX = subsx; this.subsampley = subsy; this.transparency = srcColorModel.getTransparency(); if (LOGGER.isLoggable(Level.FINER)) { LOGGER.finer("Transparency is: " + transparency);
result = createBuffered( pOriginal.getWidth(), pOriginal.getHeight(), pOriginal.getType(), pOriginal.getColorModel().getTransparency() );
if (cm.getTransparency() != Transparency.BITMASK && cm.getTransparency() != Transparency.TRANSLUCENT) { return false;
adjustQuality(pFormatQuality, FORMAT_WBMP, 0.009f); if (pImage.getColorModel().getTransparency() != Transparency.BITMASK) { adjustQuality(pFormatQuality, FORMAT_GIF, 0.8f);
@Test public void testApplyClippingPath() throws IOException { BufferedImage source = new BufferedImage(20, 20, BufferedImage.TYPE_3BYTE_BGR); Path2D path = readExpectedPath("/ser/grape-path.ser"); BufferedImage image = Paths.applyClippingPath(path, source); assertNotNull(image); // Same dimensions as original assertEquals(source.getWidth(), image.getWidth()); assertEquals(source.getHeight(), image.getHeight()); // Transparent assertTrue(image.getColorModel().getTransparency() == Transparency.TRANSLUCENT); // Corners (at least) should be transparent assertEquals(0, image.getRGB(0, 0)); assertEquals(0, image.getRGB(source.getWidth() - 1, 0)); assertEquals(0, image.getRGB(0, source.getHeight() - 1)); assertEquals(0, image.getRGB(source.getWidth() - 1, source.getHeight() - 1)); // Center opaque assertEquals(0xff, image.getRGB(source.getWidth() / 2, source.getHeight() / 2) >>> 24); // TODO: Mor sophisticated test that tests all pixels outside path... }
@Test public void testReadClipped() throws IOException { BufferedImage image = Paths.readClipped(resourceAsIIOStream("/jpeg/grape_with_path.jpg")); assertNotNull(image); // Same dimensions as original assertEquals(857, image.getWidth()); assertEquals(1800, image.getHeight()); // Transparent assertTrue(image.getColorModel().getTransparency() == Transparency.TRANSLUCENT); // Corners (at least) should be transparent assertEquals(0, image.getRGB(0, 0)); assertEquals(0, image.getRGB(image.getWidth() - 1, 0)); assertEquals(0, image.getRGB(0, image.getHeight() - 1)); assertEquals(0, image.getRGB(image.getWidth() - 1, image.getHeight() - 1)); // Center opaque assertEquals(0xff, image.getRGB(image.getWidth() / 2, image.getHeight() / 2) >>> 24); // TODO: Mor sophisticated test that tests all pixels outside path... }
if (isNonAlphaFormat(outputType) && image.getColorModel().getTransparency() != Transparency.OPAQUE) { image = ImageUtil.toBuffered(image, BufferedImage.TYPE_INT_RGB); (image.getColorModel().getTransparency() == Transparency.OPAQUE ? ImageUtil.TRANSPARENCY_OPAQUE : ImageUtil.TRANSPARENCY_BITMASK) | ImageUtil.DITHER_DIFFUSION_ALTSCANS );
/** * Used to define a cube of the color space. The cube can be split * approximately in half to generate two cubes. */ private static class Cube { int[] min = {0, 0, 0}; int[] max = {255, 255, 255}; boolean done = false; List<Counter>[] colors = null; int count = 0; static final int RED = 0; static final int GRN = 1; static final int BLU = 2; /** * Define a new cube. * * @param colors contains the 3D color histogram to be subdivided * @param count the total number of pixels in the 3D histogram. */ public Cube(List<Counter>[] colors, int count) { this.colors = colors; this.count = count; } /** * If this returns true then the cube can not be subdivided any * further * * @return true if cube can not be subdivided any further
oldCm.getTransparency(), // What alpha values can be represented.
@Test public void testGetColorModelGIF() { URL resource = getClass().getResource("/tux.gif"); assertNotNull(resource); Image source = Toolkit.getDefaultToolkit().createImage(resource); assertNotNull(source); BufferedImageFactory factory = new BufferedImageFactory(source); ColorModel colorModel = factory.getColorModel(); assertNotNull(colorModel); assertEquals(3, colorModel.getNumColorComponents()); assertEquals(ColorSpace.getInstance(ColorSpace.CS_sRGB), colorModel.getColorSpace()); assertTrue(colorModel instanceof IndexColorModel); assertTrue(colorModel.hasAlpha()); assertEquals(4, colorModel.getNumComponents()); assertTrue(((IndexColorModel) colorModel).getTransparentPixel() >= 0); assertEquals(Transparency.BITMASK, colorModel.getTransparency()); for (int i = 0; i < colorModel.getNumComponents(); i++) { assertEquals(8, colorModel.getComponentSize(i)); } }
final int tr = inputRI.getColorModel().getTransparency();
Color backgroundColor = getBackgroundColor(); if (cmref instanceof IndexColorModel && (cmref.getTransparency() != IndexColorModel.OPAQUE || images[0].getProperty("ROI") instanceof ROI) && backgroundColor != null) {
/** * Returns {@code true} if the {@linkplain #image} is * {@linkplain Transparency#TRANSLUCENT translucent}. * * @see #forceBitmaskIndexColorModel */ public final boolean isTranslucent() { return image.getColorModel().getTransparency() == Transparency.TRANSLUCENT; }
/** * Returns {@code true} if the {@linkplain #image} is * {@linkplain Transparency#TRANSLUCENT translucent}. * * @see #forceBitmaskIndexColorModel */ public final boolean isTranslucent() { return image.getColorModel().getTransparency() == Transparency.TRANSLUCENT; }
/** * Scales the image using the Java2D API, with the resultant * image optimized for the given graphics configuration. */ public static BufferedImage scale2D(BufferedImage image, int width, int height, Object hint, GraphicsConfiguration gc) { if (gc == null) gc = getDefaultConfiguration(); int trans = image.getColorModel().getTransparency(); return copyScaled(image, gc.createCompatibleImage(width, height, trans), hint); }
/** * Scales the image using the Java2D API, with the resultant * image optimized for the given graphics configuration. */ public static BufferedImage scale2D(BufferedImage image, int width, int height, Object hint, GraphicsConfiguration gc) { if (gc == null) gc = getDefaultConfiguration(); int trans = image.getColorModel().getTransparency(); return copyScaled(image, gc.createCompatibleImage(width, height, trans), hint); }
cm.hasAlpha(), cm.isAlphaPremultiplied(), cm.getTransparency(), cm.getTransferType()); sm = cm.createCompatibleSampleModel(sm.getWidth(), sm.getHeight());
double[] bgValues = null; PlanarImage[] alphaChannels = null; final int transparencyType = cm.getTransparency();