java.awt.image.BufferedImage#TYPE_INT_ARGB_PRE源码实例Demo

下面列出了java.awt.image.BufferedImage#TYPE_INT_ARGB_PRE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jdk8u60   文件: OGLBlitLoops.java
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);
    }
}
 
源代码2 项目: jdk8u-jdk   文件: MultiResolutionDragImageTest.java
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;
    }
 
源代码3 项目: dragonwell8_jdk   文件: OGLBlitLoops.java
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);
    }
}
 
源代码4 项目: pumpernickel   文件: BmpEncoder.java
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);
	}
}
 
源代码5 项目: openjdk-jdk8u   文件: OGLBlitLoops.java
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);
    }
}
 
源代码6 项目: ShootOFF   文件: SwingFXUtils.java
/**
 * 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);
	}
}
 
源代码7 项目: jdk8u-jdk   文件: JLightweightFrame.java
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);
}
 
源代码8 项目: jdk8u-dev-jdk   文件: AquaIcon.java
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;
}
 
源代码9 项目: jdk8u60   文件: CPrinterJob.java
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;
}
 
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;
    }
 
源代码11 项目: hottub   文件: AquaInternalFrameDockIconUI.java
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);
}
 
源代码12 项目: jdk8u_jdk   文件: AquaImageFactory.java
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;
}
 
源代码13 项目: LowPolyWater   文件: IconLoader.java
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);
}
 
源代码14 项目: Bytecoder   文件: ImageRepresentation.java
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;
        }
    }
}
 
源代码15 项目: openjdk-jdk8u-backup   文件: Destinations.java
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();
    }
}
 
源代码16 项目: jdk8u-jdk   文件: AquaImageFactory.java
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;
    }
 
源代码17 项目: TencentKona-8   文件: OGLBlitLoops.java
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);
    }
}
 
源代码18 项目: openjdk-jdk8u-backup   文件: ColConvTest.java
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";
}
 
源代码19 项目: jdk8u-jdk   文件: CPrinterJob.java
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;
}
 
源代码20 项目: jdk8u60   文件: ImageRepresentation.java
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;
        }
    }
}