Java Code Examples for java.awt.image.BufferedImage#TYPE_INT_ARGB_PRE
The following examples show how to use
java.awt.image.BufferedImage#TYPE_INT_ARGB_PRE .
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: AquaInternalFrameDockIconUI.java From hottub with GNU General Public License v2.0 | 5 votes |
void updateIcon() { final Object priorIcon = fFrame.getClientProperty(CACHED_FRAME_ICON_KEY); if (priorIcon instanceof ImageIcon) { setIcon((ImageIcon)priorIcon); return; } int width = fFrame.getWidth(); int height = fFrame.getHeight(); // Protect us from unsized frames, like in JCK test DefaultDesktopManager2008 if (width <= 0 || height <= 0) { width = 128; height = 128; } final Image fImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB_PRE); final Graphics g = fImage.getGraphics(); fFrame.paint(g); g.dispose(); final float scale = (float)fDesktopIcon.getWidth() / (float)Math.max(width, height) * 0.89f; // Sending in -1 for width xor height causes it to maintain aspect ratio final ImageIcon icon = new ImageIcon(fImage.getScaledInstance((int)(width * scale), -1, Image.SCALE_SMOOTH)); fFrame.putClientProperty(CACHED_FRAME_ICON_KEY, icon); setIcon(icon); }
Example 2
Source File: ImageRepresentation.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
void createBufferedImage() { // REMIND: Be careful! Is this called everytime there is a // startProduction? We only want to call it if it is new or // there is an error isDefaultBI = false; try { biRaster = cmodel.createCompatibleWritableRaster(width, height); bimage = createImage(cmodel, biRaster, cmodel.isAlphaPremultiplied(), null); } catch (Exception e) { // Create a default image cmodel = ColorModel.getRGBdefault(); biRaster = cmodel.createCompatibleWritableRaster(width, height); bimage = createImage(cmodel, biRaster, false, null); } int type = bimage.getType(); if ((cmodel == ColorModel.getRGBdefault()) || (type == BufferedImage.TYPE_INT_RGB) || (type == BufferedImage.TYPE_INT_ARGB_PRE)) { isDefaultBI = true; } else if (cmodel instanceof DirectColorModel) { DirectColorModel dcm = (DirectColorModel) cmodel; if (dcm.getRedMask() == 0xff0000 && dcm.getGreenMask() == 0xff00 && dcm.getBlueMask() == 0xff) { isDefaultBI = true; } } }
Example 3
Source File: CPrinterJob.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private PeekGraphics createFirstPassGraphics(PrinterJob printerJob, PageFormat page) { // This is called from the native side. BufferedImage bimg = new BufferedImage((int)Math.round(page.getWidth()), (int)Math.round(page.getHeight()), BufferedImage.TYPE_INT_ARGB_PRE); PeekGraphics peekGraphics = createPeekGraphics(bimg.createGraphics(), printerJob); Rectangle2D pageFormatArea = getPageFormatArea(page); initPrinterGraphics(peekGraphics, pageFormatArea); return peekGraphics; }
Example 4
Source File: ColConvTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static String getImageTypeName(int type) { switch(type) { case BufferedImage.TYPE_INT_ARGB: return "TYPE_INT_ARGB"; case BufferedImage.TYPE_INT_RGB: return "TYPE_INT_RGB"; case BufferedImage.TYPE_INT_BGR: return "TYPE_INT_BGR"; case BufferedImage.TYPE_INT_ARGB_PRE: return "TYPE_INT_ARGB_PRE"; case BufferedImage.TYPE_3BYTE_BGR: return "TYPE_3BYTE_BGR"; case BufferedImage.TYPE_4BYTE_ABGR: return "TYPE_4BYTE_ABGR"; case BufferedImage.TYPE_4BYTE_ABGR_PRE: return "TYPE_4BYTE_ABGR_PRE"; case BufferedImage.TYPE_BYTE_BINARY: return "TYPE_BYTE_BINARY"; case BufferedImage.TYPE_BYTE_GRAY: return "TYPE_BYTE_GRAY"; case BufferedImage.TYPE_BYTE_INDEXED: return "TYPE_BYTE_INDEXED"; case BufferedImage.TYPE_USHORT_555_RGB: return "TYPE_USHORT_555_RGB"; case BufferedImage.TYPE_USHORT_565_RGB: return "TYPE_USHORT_565_RGB"; case BufferedImage.TYPE_USHORT_GRAY: return "TYPE_USHORT_GRAY"; } return "UNKNOWN"; }
Example 5
Source File: OGLBlitLoops.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private synchronized void complexClipBlit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) { SurfaceData cachedSrc = null; if (srcTmp != null) { // use cached intermediate surface, if available cachedSrc = srcTmp.get(); } // We can convert argb_pre data from OpenGL surface in two places: // - During OpenGL surface -> SW blit // - During SW -> SW blit // The first one is faster when we use opaque OGL surface, because in // this case we simply skip conversion and use color components as is. // Because of this we align intermediate buffer type with type of // destination not source. final int type = typeval == OGLSurfaceData.PF_INT_ARGB_PRE ? BufferedImage.TYPE_INT_ARGB_PRE : BufferedImage.TYPE_INT_ARGB; src = convertFrom(this, src, sx, sy, w, h, cachedSrc, type); // copy intermediate SW to destination SW using complex clip final Blit performop = Blit.getFromCache(src.getSurfaceType(), CompositeType.SrcNoEa, dst.getSurfaceType()); performop.Blit(src, dst, comp, clip, 0, 0, dx, dy, w, h); if (src != cachedSrc) { // cache the intermediate surface srcTmp = new WeakReference<>(src); } }
Example 6
Source File: AquaImageFactory.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
static BufferedImage getAppIconImageCompositedOn(final Image background, int scaleFactor) { final int scaledAlertIconSize = kAlertIconSize * scaleFactor; final int kAlertSubIconSize = (int) (scaledAlertIconSize * 0.5); final int kAlertSubIconInset = scaledAlertIconSize - kAlertSubIconSize; final Icon smallAppIconScaled = new AquaIcon.CachingScalingIcon( kAlertSubIconSize, kAlertSubIconSize) { Image createImage() { return getGenericJavaIcon(); } }; final BufferedImage image = new BufferedImage(scaledAlertIconSize, scaledAlertIconSize, BufferedImage.TYPE_INT_ARGB_PRE); final Graphics g = image.getGraphics(); g.drawImage(background, 0, 0, scaledAlertIconSize, scaledAlertIconSize, null); if (g instanceof Graphics2D) { // improves icon rendering quality in Quartz ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); } smallAppIconScaled.paintIcon(null, g, kAlertSubIconInset, kAlertSubIconInset); g.dispose(); return image; }
Example 7
Source File: Destinations.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void init() { destroot = new Group.EnableSet(TestEnvironment.globaloptroot, "dest", "Output Destination Options"); new Screen(); new OffScreen(); if (GraphicsTests.hasGraphics2D) { if (ImageTests.hasCompatImage) { compatimgdestroot = new Group.EnableSet(destroot, "compatimg", "Compatible Image Destinations"); compatimgdestroot.setHorizontal(); new CompatImg(); new CompatImg(Transparency.OPAQUE); new CompatImg(Transparency.BITMASK); new CompatImg(Transparency.TRANSLUCENT); } if (ImageTests.hasVolatileImage) { new VolatileImg(); } bufimgdestroot = new Group.EnableSet(destroot, "bufimg", "BufferedImage Destinations"); new BufImg(BufferedImage.TYPE_INT_RGB); new BufImg(BufferedImage.TYPE_INT_ARGB); new BufImg(BufferedImage.TYPE_INT_ARGB_PRE); new BufImg(BufferedImage.TYPE_3BYTE_BGR); new BufImg(BufferedImage.TYPE_BYTE_INDEXED); new BufImg(BufferedImage.TYPE_BYTE_GRAY); new CustomImg(); } }
Example 8
Source File: ImageRepresentation.java From Bytecoder with Apache License 2.0 | 5 votes |
void createBufferedImage() { // REMIND: Be careful! Is this called everytime there is a // startProduction? We only want to call it if it is new or // there is an error isDefaultBI = false; try { biRaster = cmodel.createCompatibleWritableRaster(width, height); bimage = createImage(cmodel, biRaster, cmodel.isAlphaPremultiplied(), null); } catch (Exception e) { // Create a default image cmodel = ColorModel.getRGBdefault(); biRaster = cmodel.createCompatibleWritableRaster(width, height); bimage = createImage(cmodel, biRaster, false, null); } int type = bimage.getType(); if ((cmodel == ColorModel.getRGBdefault()) || (type == BufferedImage.TYPE_INT_RGB) || (type == BufferedImage.TYPE_INT_ARGB_PRE)) { isDefaultBI = true; } else if (cmodel instanceof DirectColorModel) { DirectColorModel dcm = (DirectColorModel) cmodel; if (dcm.getRedMask() == 0xff0000 && dcm.getGreenMask() == 0xff00 && dcm.getBlueMask() == 0xff) { isDefaultBI = true; } } }
Example 9
Source File: IconLoader.java From LowPolyWater with The Unlicense | 5 votes |
private static ByteBuffer loadInstance(BufferedImage image, int dimension) { BufferedImage scaledIcon = new BufferedImage(dimension, dimension, BufferedImage.TYPE_INT_ARGB_PRE); Graphics2D g = scaledIcon.createGraphics(); double ratio = getIconRatio(image, scaledIcon); double width = image.getWidth() * ratio; double height = image.getHeight() * ratio; g.drawImage(image, (int) ((scaledIcon.getWidth() - width) / 2), (int) ((scaledIcon.getHeight() - height) / 2), (int) (width), (int) (height), null); g.dispose(); return convertToByteBuffer(scaledIcon); }
Example 10
Source File: AquaImageFactory.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
static BufferedImage createSlice(final Image img, final int x, final int y, final int w, final int h) { if (w == 0 || h == 0) return null; final BufferedImage slice = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE); final Graphics2D g2d = slice.createGraphics(); g2d.drawImage(img, 0, 0, w, h, x, y, x + w, y + h, null); g2d.dispose(); return slice; }
Example 11
Source File: OGLBlitLoops.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private synchronized void complexClipBlit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) { SurfaceData cachedSrc = null; if (srcTmp != null) { // use cached intermediate surface, if available cachedSrc = srcTmp.get(); } // We can convert argb_pre data from OpenGL surface in two places: // - During OpenGL surface -> SW blit // - During SW -> SW blit // The first one is faster when we use opaque OGL surface, because in // this case we simply skip conversion and use color components as is. // Because of this we align intermediate buffer type with type of // destination not source. final int type = typeval == OGLSurfaceData.PF_INT_ARGB_PRE ? BufferedImage.TYPE_INT_ARGB_PRE : BufferedImage.TYPE_INT_ARGB; src = convertFrom(this, src, sx, sy, w, h, cachedSrc, type); // copy intermediate SW to destination SW using complex clip final Blit performop = Blit.getFromCache(src.getSurfaceType(), CompositeType.SrcNoEa, dst.getSurfaceType()); performop.Blit(src, dst, comp, clip, 0, 0, dx, dy, w, h); if (src != cachedSrc) { // cache the intermediate surface srcTmp = new WeakReference<>(src); } }
Example 12
Source File: MultiResolutionDragImageTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static Image createImage(final int length, final Color color) { final BufferedImage image = new BufferedImage(length, length, BufferedImage.TYPE_INT_ARGB_PRE); final Graphics graphics = image.getGraphics(); graphics.setColor(color); graphics.fillRect(0, 0, length, length); graphics.dispose(); return image; }
Example 13
Source File: CPrinterJob.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private PeekGraphics createFirstPassGraphics(PrinterJob printerJob, PageFormat page) { // This is called from the native side. BufferedImage bimg = new BufferedImage((int)Math.round(page.getWidth()), (int)Math.round(page.getHeight()), BufferedImage.TYPE_INT_ARGB_PRE); PeekGraphics peekGraphics = createPeekGraphics(bimg.createGraphics(), printerJob); Rectangle2D pageFormatArea = getPageFormatArea(page); initPrinterGraphics(peekGraphics, pageFormatArea); return peekGraphics; }
Example 14
Source File: AquaIcon.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public static Image getImageForIcon(final Icon i) { if (i instanceof ImageIcon) return ((ImageIcon)i).getImage(); final int w = i.getIconWidth(); final int h = i.getIconHeight(); if (w <= 0 || h <= 0) return null; // This could be any kind of icon, so we need to make a buffer for it, draw it and then pass the new image off to appkit. final BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB_PRE); final Graphics g = image.getGraphics(); i.paintIcon(null, g, 0, 0); g.dispose(); return image; }
Example 15
Source File: JLightweightFrame.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private void resizeBuffer(int width, int height, int newScaleFactor) { bbImage = new BufferedImage(width*newScaleFactor,height*newScaleFactor, BufferedImage.TYPE_INT_ARGB_PRE); int[] pixels= ((DataBufferInt)bbImage.getRaster().getDataBuffer()).getData(); if (copyBufferEnabled) { syncCopyBuffer(true, 0, 0, width, height, newScaleFactor); pixels = copyBuffer; } content.imageBufferReset(pixels, 0, 0, width, height, width * newScaleFactor, newScaleFactor); }
Example 16
Source File: SwingFXUtils.java From ShootOFF with GNU General Public License v3.0 | 5 votes |
/** * Determine the optimal BufferedImage type to use for the specified * {@code fxFormat} allowing for the specified {@code bimg} to be use as a * potential default storage space if it is not null and is compatible. * * @param fxFormat * the PixelFormat of the source FX Image * @param bimg * an optional existing {@code BufferedImage} to be used for * storage if it is compatible, or null * @return */ private static int getBestBufferedImageType(PixelFormat<?> fxFormat, BufferedImage bimg) { if (bimg != null) { int bimgType = bimg.getType(); if (bimgType == BufferedImage.TYPE_INT_ARGB || bimgType == BufferedImage.TYPE_INT_ARGB_PRE) { // We will allow the caller to give us a BufferedImage // that has an alpha channel, but we might not otherwise // construct one ourselves. // We will also allow them to choose their own premultiply // type which may not match the image. // If left to our own devices we might choose a more specific // format as indicated by the choices below. return bimgType; } } switch (fxFormat.getType()) { default: case BYTE_BGRA_PRE: case INT_ARGB_PRE: return BufferedImage.TYPE_INT_ARGB_PRE; case BYTE_BGRA: case INT_ARGB: return BufferedImage.TYPE_INT_ARGB; case BYTE_RGB: return BufferedImage.TYPE_INT_RGB; case BYTE_INDEXED: return (fxFormat.isPremultiplied() ? BufferedImage.TYPE_INT_ARGB_PRE : BufferedImage.TYPE_INT_ARGB); } }
Example 17
Source File: OGLBlitLoops.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private synchronized void complexClipBlit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) { SurfaceData cachedSrc = null; if (srcTmp != null) { // use cached intermediate surface, if available cachedSrc = srcTmp.get(); } // We can convert argb_pre data from OpenGL surface in two places: // - During OpenGL surface -> SW blit // - During SW -> SW blit // The first one is faster when we use opaque OGL surface, because in // this case we simply skip conversion and use color components as is. // Because of this we align intermediate buffer type with type of // destination not source. final int type = typeval == OGLSurfaceData.PF_INT_ARGB_PRE ? BufferedImage.TYPE_INT_ARGB_PRE : BufferedImage.TYPE_INT_ARGB; src = convertFrom(this, src, sx, sy, w, h, cachedSrc, type); // copy intermediate SW to destination SW using complex clip final Blit performop = Blit.getFromCache(src.getSurfaceType(), CompositeType.SrcNoEa, dst.getSurfaceType()); performop.Blit(src, dst, comp, clip, 0, 0, dx, dy, w, h); if (src != cachedSrc) { // cache the intermediate surface srcTmp = new WeakReference<>(src); } }
Example 18
Source File: BmpEncoder.java From pumpernickel with MIT License | 5 votes |
public static boolean isOpaque(BufferedImage bi) { try { Method m = BufferedImage.class.getMethod("getTransparency", new Class[] {}); Object returnValue = m.invoke(bi, new Object[] {}); Field f = BufferedImage.class.getField("OPAQUE"); return f.get(null).equals(returnValue); } catch (Throwable e) { // in earlier JVMs this will be a problem: int type = bi.getType(); return (type == BufferedImage.TYPE_4BYTE_ABGR || type == BufferedImage.TYPE_4BYTE_ABGR_PRE || type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_ARGB_PRE); } }
Example 19
Source File: OGLBlitLoops.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private synchronized void complexClipBlit(SurfaceData src, SurfaceData dst, Composite comp, Region clip, int sx, int sy, int dx, int dy, int w, int h) { SurfaceData cachedSrc = null; if (srcTmp != null) { // use cached intermediate surface, if available cachedSrc = srcTmp.get(); } // We can convert argb_pre data from OpenGL surface in two places: // - During OpenGL surface -> SW blit // - During SW -> SW blit // The first one is faster when we use opaque OGL surface, because in // this case we simply skip conversion and use color components as is. // Because of this we align intermediate buffer type with type of // destination not source. final int type = typeval == OGLSurfaceData.PF_INT_ARGB_PRE ? BufferedImage.TYPE_INT_ARGB_PRE : BufferedImage.TYPE_INT_ARGB; src = convertFrom(this, src, sx, sy, w, h, cachedSrc, type); // copy intermediate SW to destination SW using complex clip final Blit performop = Blit.getFromCache(src.getSurfaceType(), CompositeType.SrcNoEa, dst.getSurfaceType()); performop.Blit(src, dst, comp, clip, 0, 0, dx, dy, w, h); if (src != cachedSrc) { // cache the intermediate surface srcTmp = new WeakReference<>(src); } }
Example 20
Source File: MultiResolutionDragImageTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static Image createImage(final int length, final Color color) { final BufferedImage image = new BufferedImage(length, length, BufferedImage.TYPE_INT_ARGB_PRE); final Graphics graphics = image.getGraphics(); graphics.setColor(color); graphics.fillRect(0, 0, length, length); graphics.dispose(); return image; }