This method returns a buffered image with the contents of an image

@param  image the image to copy into a buffered image.

@return the buffered image containing the image.
974043
protected static BufferedImage toBufferedImage(Image image) {
        if (image instanceof BufferedImage) {
            return (BufferedImage) image;
        }

        // This code ensures that all the pixels in the image are loaded
        image = new ImageIcon(image).getImage();

        // Determine if the image has transparent pixels; for this method's
        // implementation, see e661 Determining If an Image Has Transparent
        // Pixels
        boolean hasAlpha = hasAlpha(image);

        // Create a buffered image with a format that's compatible with the
        // screen
        BufferedImage       bimage = null;
        GraphicsEnvironment ge     = GraphicsEnvironment.getLocalGraphicsEnvironment();

        try {

            // Determine the type of transparency of the new buffered image
            int transparency = Transparency.OPAQUE;

            if (hasAlpha) {
                transparency = Transparency.BITMASK;
            }

            // Create the buffered image
            GraphicsDevice        gs = ge.getDefaultScreenDevice();
            GraphicsConfiguration gc = gs.getDefaultConfiguration();

            bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency);
        } catch (HeadlessException e) {
            // The system does not have a screen
        }

        if (bimage == null) {

            // Create a buffered image using the default color model
            int type = BufferedImage.TYPE_INT_RGB;

            if (hasAlpha) {
                type = BufferedImage.TYPE_INT_ARGB;
            }

            bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type);
        }

        // Copy image to buffered image
        Graphics g = bimage.createGraphics();

        // Paint the image onto the buffered image
        g.drawImage(image, 0, 0, null);
        g.dispose();

        return bimage;
    }
759092
public static BufferedImage cloneImage( BufferedImage image ) {
		BufferedImage newImage = new BufferedImage( image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB );
		Graphics2D g = newImage.createGraphics();
		g.drawRenderedImage( image, null );
		g.dispose();
		return newImage;
	}
1152311
public static BufferedImage convertToBufferedImage(Image img) {
        BufferedImage buff = createCompatibleTranslucentImage(
                img.getWidth(null), img.getHeight(null));
        Graphics2D g2 = buff.createGraphics();

        try {
            g2.drawImage(img, 0, 0, null);
        } finally {
            g2.dispose();
        }

        return buff;
    }
1313891
public static boolean canWrite (BufferedImage image)
    {
        return (image.getColorModel() instanceof IndexColorModel) &&
            (image.getRaster().getDataBuffer() instanceof DataBufferByte);
    }
1178065
public byte[] getImageBytes(BufferedImage image) {
		byte[] bytes = null;
		try {
			bytes = ImageUtils.writeImageToBytes(image,
					ImageUtils.IMAGE_FORMAT_PNG);
		} catch (IOException e) {
			throw new GeoPackageException("Failed to write image to "
					+ ImageUtils.IMAGE_FORMAT_PNG + " bytes", e);
		}
		return bytes;
	}
462215
protected BufferedImage create_FRAME_Image(final int WIDTH, final int HEIGHT, final BufferedImage IMAGE) {
        return FRAME_FACTORY.createLinearFrame(WIDTH, HEIGHT, getFrameDesign(), getCustomFrameDesign(), getFrameBaseColor(), isFrameBaseColorEnabled(), getFrameEffect(), IMAGE);
    }
1346537
public BufferedImage getBufferedImage()
    {
        if (image == null || abort)
            return null;
        
        // no container that would repaint -- wait for the complete image
        if (container == null)
            waitForLoad();
        
        BufferedImage img = new BufferedImage(getIntrinsicWidth(), getIntrinsicHeight(), BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = img.createGraphics();
        g.drawImage(image, null, null);
        g.dispose();

        return img;
    }
1354578
private BufferedImage create_FRAME_Image(final int WIDTH, BufferedImage image) {
        if (WIDTH <= 0) {
            return null;
        }
        final double VERTICAL_SCALE;

        if (image == null) {
            image = UTIL.createImage(WIDTH, (int) (0.641860465116279 * WIDTH), Transparency.TRANSLUCENT);
            VERTICAL_SCALE = 1.0;
        } else {
            VERTICAL_SCALE = 0.641860465116279;
        }
        final Graphics2D G2 = image.createGraphics();
        G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);

        final int IMAGE_WIDTH = image.getWidth();
        final int IMAGE_HEIGHT = image.getHeight();

        // Define shape that will be subtracted from frame shapes
        final GeneralPath SUBTRACT_PATH = new GeneralPath();
        SUBTRACT_PATH.setWindingRule(Path2D.WIND_EVEN_ODD);
        SUBTRACT_PATH.moveTo(IMAGE_WIDTH * 0.08372093023255814, IMAGE_HEIGHT * 0.7753623188405797 * VERTICAL_SCALE);
        SUBTRACT_PATH.curveTo(IMAGE_WIDTH * 0.08372093023255814, IMAGE_HEIGHT * 0.42028985507246375 * VERTICAL_SCALE, IMAGE_WIDTH * 0.26976744186046514, IMAGE_HEIGHT * 0.13043478260869565 * VERTICAL_SCALE, IMAGE_WIDTH * 0.49767441860465117, IMAGE_HEIGHT * 0.13043478260869565 * VERTICAL_SCALE);
        SUBTRACT_PATH.curveTo(IMAGE_WIDTH * 0.7255813953488373, IMAGE_HEIGHT * 0.13043478260869565 * VERTICAL_SCALE, IMAGE_WIDTH * 0.9116279069767442, IMAGE_HEIGHT * 0.42028985507246375 * VERTICAL_SCALE, IMAGE_WIDTH * 0.9116279069767442, IMAGE_HEIGHT * 0.7753623188405797 * VERTICAL_SCALE);
        SUBTRACT_PATH.curveTo(IMAGE_WIDTH * 0.9116279069767442, IMAGE_HEIGHT * 0.8188405797101449 * VERTICAL_SCALE, IMAGE_WIDTH * 0.9069767441860465, IMAGE_HEIGHT * 0.8695652173913043 * VERTICAL_SCALE, IMAGE_WIDTH * 0.9069767441860465, IMAGE_HEIGHT * 0.8695652173913043 * VERTICAL_SCALE);
        SUBTRACT_PATH.lineTo(IMAGE_WIDTH * 0.08837209302325581, IMAGE_HEIGHT * 0.8695652173913043 * VERTICAL_SCALE);
        SUBTRACT_PATH.curveTo(IMAGE_WIDTH * 0.08837209302325581, IMAGE_HEIGHT * 0.8695652173913043 * VERTICAL_SCALE, IMAGE_WIDTH * 0.08372093023255814, IMAGE_HEIGHT * 0.8115942028985508 * VERTICAL_SCALE, IMAGE_WIDTH * 0.08372093023255814, IMAGE_HEIGHT * 0.7753623188405797 * VERTICAL_SCALE);
        SUBTRACT_PATH.closePath();
        final Area SUBTRACT = new Area(SUBTRACT_PATH);

        final GeneralPath FRAME_OUTERFRAME = new GeneralPath();
        FRAME_OUTERFRAME.setWindingRule(Path2D.WIND_EVEN_ODD);
        FRAME_OUTERFRAME.moveTo(0.0, IMAGE_HEIGHT * 0.7753623188405797 * VERTICAL_SCALE);
        FRAME_OUTERFRAME.curveTo(0.0, IMAGE_HEIGHT * 0.34782608695652173 * VERTICAL_SCALE, IMAGE_WIDTH * 0.22325581395348837, 0.0, IMAGE_WIDTH * 0.49767441860465117, 0.0);
        FRAME_OUTERFRAME.curveTo(IMAGE_WIDTH * 0.772093023255814, 0.0, IMAGE_WIDTH, IMAGE_HEIGHT * 0.34782608695652173 * VERTICAL_SCALE, IMAGE_WIDTH, IMAGE_HEIGHT * 0.7753623188405797 * VERTICAL_SCALE);
        FRAME_OUTERFRAME.curveTo(IMAGE_WIDTH, IMAGE_HEIGHT * 0.9057971014492754 * VERTICAL_SCALE, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_WIDTH, IMAGE_HEIGHT * VERTICAL_SCALE);
        FRAME_OUTERFRAME.lineTo(0.0, IMAGE_HEIGHT * VERTICAL_SCALE);
        FRAME_OUTERFRAME.curveTo(0.0, IMAGE_HEIGHT * VERTICAL_SCALE, 0.0, IMAGE_HEIGHT * 0.8985507246376812 * VERTICAL_SCALE, 0.0, IMAGE_HEIGHT * 0.7753623188405797 * VERTICAL_SCALE);
        FRAME_OUTERFRAME.closePath();
        G2.setPaint(getOuterFrameColor());
        final Area FRAME_OUTERFRAME_AREA = new Area(FRAME_OUTERFRAME);
        FRAME_OUTERFRAME_AREA.subtract(SUBTRACT);
        G2.fill(FRAME_OUTERFRAME_AREA);

        final GeneralPath FRAME_MAIN = new GeneralPath();
        FRAME_MAIN.setWindingRule(Path2D.WIND_EVEN_ODD);
        FRAME_MAIN.moveTo(IMAGE_WIDTH * 0.004651162790697674, IMAGE_HEIGHT * 0.7753623188405797 * VERTICAL_SCALE);
        FRAME_MAIN.curveTo(IMAGE_WIDTH * 0.004651162790697674, IMAGE_HEIGHT * 0.34782608695652173 * VERTICAL_SCALE, IMAGE_WIDTH * 0.22325581395348837, IMAGE_HEIGHT * 0.007246376811594203 * VERTICAL_SCALE, IMAGE_WIDTH * 0.49767441860465117, IMAGE_HEIGHT * 0.007246376811594203 * VERTICAL_SCALE);
        FRAME_MAIN.curveTo(IMAGE_WIDTH * 0.772093023255814, IMAGE_HEIGHT * 0.007246376811594203 * VERTICAL_SCALE, IMAGE_WIDTH * 0.9953488372093023, IMAGE_HEIGHT * 0.35507246376811596 * VERTICAL_SCALE, IMAGE_WIDTH * 0.9953488372093023, IMAGE_HEIGHT * 0.7753623188405797 * VERTICAL_SCALE);
        FRAME_MAIN.curveTo(IMAGE_WIDTH * 0.9953488372093023, IMAGE_HEIGHT * 0.8840579710144928 * VERTICAL_SCALE, IMAGE_WIDTH * 0.9953488372093023, IMAGE_HEIGHT * 0.9927536231884058 * VERTICAL_SCALE, IMAGE_WIDTH * 0.9953488372093023, IMAGE_HEIGHT * 0.9927536231884058 * VERTICAL_SCALE);
        FRAME_MAIN.lineTo(IMAGE_WIDTH * 0.004651162790697674, IMAGE_HEIGHT * 0.9927536231884058 * VERTICAL_SCALE);
        FRAME_MAIN.curveTo(IMAGE_WIDTH * 0.004651162790697674, IMAGE_HEIGHT * 0.9927536231884058 * VERTICAL_SCALE, IMAGE_WIDTH * 0.004651162790697674, IMAGE_HEIGHT * 0.8840579710144928 * VERTICAL_SCALE, IMAGE_WIDTH * 0.004651162790697674, IMAGE_HEIGHT * 0.7753623188405797 * VERTICAL_SCALE);
        FRAME_MAIN.closePath();

        final Point2D FRAME_MAIN_START = new Point2D.Double(0, FRAME_MAIN.getBounds2D().getMinY());
        final Point2D FRAME_MAIN_STOP = new Point2D.Double(0, FRAME_MAIN.getBounds2D().getMaxY());
        final Point2D FRAME_MAIN_CENTER = new Point2D.Double(FRAME_MAIN.getBounds2D().getCenterX(), FRAME_MAIN.getBounds2D().getHeight() * 0.7753623188 * VERTICAL_SCALE);

        final Area FRAME_MAIN_AREA = new Area(FRAME_MAIN);

        if (getFrameDesign() == FrameDesign.CUSTOM) {
            G2.setPaint(getCustomFrameDesign());
            FRAME_MAIN_AREA.subtract(SUBTRACT);
            G2.fill(FRAME_MAIN_AREA);
        } else {
            switch (getFrameDesign()) {
                case BLACK_METAL:
                    float[] frameMainFractions1 = {
                        0.0f,
                        45.0f,
                        85.0f,
                        180.0f,
                        275.0f,
                        315.0f,
                        360.0f
                    };

                    Color[] frameMainColors1 = {
                        new Color(254, 254, 254, 255),
                        new Color(0, 0, 0, 255),
                        new Color(0, 0, 0, 255),
                        new Color(0, 0, 0, 255),
                        new Color(0, 0, 0, 255),
                        new Color(0, 0, 0, 255),
                        new Color(254, 254, 254, 255)
                    };

                    Paint frameMainGradient1 = new ConicalGradientPaint(true, FRAME_MAIN_CENTER, 0, frameMainFractions1, frameMainColors1);
                    G2.setPaint(frameMainGradient1);
                    FRAME_MAIN_AREA.subtract(SUBTRACT);
                    G2.fill(FRAME_MAIN_AREA);
                    break;

                case METAL:
                    float[] frameMainFractions2 = {
                        0.0f,
                        0.07f,
                        0.12f,
                        1.0f
                    };

                    Color[] frameMainColors2 = {
                        new Color(254, 254, 254, 255),
                        new Color(210, 210, 210, 255),
                        new Color(179, 179, 179, 255),
                        new Color(213, 213, 213, 255)
                    };
                    Util.INSTANCE.validateGradientPoints(FRAME_MAIN_START, FRAME_MAIN_STOP);
                    Paint frameMainGradient2 = new LinearGradientPaint(FRAME_MAIN_START, FRAME_MAIN_STOP, frameMainFractions2, frameMainColors2);
                    G2.setPaint(frameMainGradient2);
                    FRAME_MAIN_AREA.subtract(SUBTRACT);
                    G2.fill(FRAME_MAIN_AREA);
                    break;

                case SHINY_METAL:
                    float[] frameMainFractions3;
                    Color[] frameMainColors3;
                    if (isFrameBaseColorEnabled()) {
                        frameMainFractions3 = new float[]{
                            0.0f,
                            45.0f,
                            90.0f,
                            135.0f,
                            180.0f,
                            225.0f,
                            270.0f,
                            315.0f,
                            360.0f
                        };

                        frameMainColors3 = new Color[]{
                            new Color(254, 254, 254, 255),
                            new Color(getFrameBaseColor().getRed(), getFrameBaseColor().getGreen(), getFrameBaseColor().getBlue(), 255),
                            new Color(getFrameBaseColor().getRed(), getFrameBaseColor().getGreen(), getFrameBaseColor().getBlue(), 255),
                            new Color(getFrameBaseColor().brighter().brighter().getRed(), getFrameBaseColor().brighter().brighter().getGreen(), getFrameBaseColor().brighter().brighter().getBlue(), 255),
                            new Color(getFrameBaseColor().getRed(), getFrameBaseColor().getGreen(), getFrameBaseColor().getBlue(), 255),
                            new Color(getFrameBaseColor().brighter().brighter().getRed(), getFrameBaseColor().brighter().brighter().getGreen(), getFrameBaseColor().brighter().brighter().getBlue(), 255),
                            new Color(getFrameBaseColor().getRed(), getFrameBaseColor().getGreen(), getFrameBaseColor().getBlue(), 255),
                            new Color(getFrameBaseColor().getRed(), getFrameBaseColor().getGreen(), getFrameBaseColor().getBlue(), 255),
                            new Color(254, 254, 254, 255)
                        };
                    } else {
                        frameMainFractions3 = new float[]{
                            0.0f,
                            45.0f,
                            90.0f,
                            95.0f,
                            180.0f,
                            265.0f,
                            270.0f,
                            315.0f,
                            360.0f
                        };

                        frameMainColors3 = new Color[]{
                            new Color(254, 254, 254, 255),
                            new Color(210, 210, 210, 255),
                            new Color(179, 179, 179, 255),
                            new Color(160, 160, 160, 255),
                            new Color(160, 160, 160, 255),
                            new Color(160, 160, 160, 255),
                            new Color(179, 179, 179, 255),
                            new Color(210, 210, 210, 255),
                            new Color(254, 254, 254, 255)
                        };
                    }

                    Paint frameMainGradient3 = new ConicalGradientPaint(true, FRAME_MAIN_CENTER, 0, frameMainFractions3, frameMainColors3);
                    G2.setPaint(frameMainGradient3);
                    FRAME_MAIN_AREA.subtract(SUBTRACT);
                    G2.fill(FRAME_MAIN_AREA);
                    break;

                case GLOSSY_METAL:
                    final GeneralPath FRAME_MAIN_GLOSSY1 = new GeneralPath();
                    FRAME_MAIN_GLOSSY1.setWindingRule(Path2D.WIND_EVEN_ODD);
                    FRAME_MAIN_GLOSSY1.moveTo(0.004672897196261682 * IMAGE_WIDTH, 0.7737226277372263 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY1.curveTo(0.004672897196261682 * IMAGE_WIDTH, 0.35036496350364965 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.22429906542056074 * IMAGE_WIDTH, 0.0072992700729927005 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.5 * IMAGE_WIDTH, 0.0072992700729927005 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY1.curveTo(0.7710280373831776 * IMAGE_WIDTH, 0.0072992700729927005 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.9953271028037384 * IMAGE_WIDTH, 0.35036496350364965 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.9953271028037384 * IMAGE_WIDTH, 0.7737226277372263 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY1.curveTo(0.9953271028037384 * IMAGE_WIDTH, 0.8832116788321168 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.9953271028037384 * IMAGE_WIDTH, 0.9927007299270073 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.9953271028037384 * IMAGE_WIDTH, 0.9927007299270073 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY1.lineTo(0.004672897196261682 * IMAGE_WIDTH, 0.9927007299270073 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY1.curveTo(0.004672897196261682 * IMAGE_WIDTH, 0.9927007299270073 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.004672897196261682 * IMAGE_WIDTH, 0.8832116788321168 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.004672897196261682 * IMAGE_WIDTH, 0.7737226277372263 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY1.closePath();
                    final Area FRAME_MAIN_GLOSSY_1 = new Area(FRAME_MAIN_GLOSSY1);
                    FRAME_MAIN_GLOSSY_1.subtract(SUBTRACT);
                    G2.setPaint(new RadialGradientPaint(new Point2D.Double(0.5 * IMAGE_WIDTH, 0.9927007299270073 * IMAGE_HEIGHT * VERTICAL_SCALE), (float)(0.4953271028037383 * IMAGE_WIDTH), new float[]{0.0f, 0.01f, 0.95f, 1.0f}, new Color[]{new Color(0.8235294118f, 0.8235294118f, 0.8235294118f, 1f), new Color(0.8235294118f, 0.8235294118f, 0.8235294118f, 1f), new Color(0.8235294118f, 0.8235294118f, 0.8235294118f, 1f), new Color(0.9960784314f, 0.9960784314f, 0.9960784314f, 1f)}));
                    G2.fill(FRAME_MAIN_GLOSSY_1);

                    final GeneralPath FRAME_MAIN_GLOSSY2 = new GeneralPath();
                    FRAME_MAIN_GLOSSY2.setWindingRule(Path2D.WIND_EVEN_ODD);
                    FRAME_MAIN_GLOSSY2.moveTo(0.014018691588785047 * IMAGE_WIDTH, 0.7737226277372263 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY2.curveTo(0.014018691588785047 * IMAGE_WIDTH, 0.36496350364963503 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.22429906542056074 * IMAGE_WIDTH, 0.021897810218978103 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.5 * IMAGE_WIDTH, 0.021897810218978103 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY2.curveTo(0.7710280373831776 * IMAGE_WIDTH, 0.021897810218978103 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.985981308411215 * IMAGE_WIDTH, 0.36496350364963503 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.985981308411215 * IMAGE_WIDTH, 0.7737226277372263 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY2.curveTo(0.985981308411215 * IMAGE_WIDTH, 0.8832116788321168 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.985981308411215 * IMAGE_WIDTH, 0.9781021897810219 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.985981308411215 * IMAGE_WIDTH, 0.9781021897810219 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY2.lineTo(0.014018691588785047 * IMAGE_WIDTH, 0.9781021897810219 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY2.curveTo(0.014018691588785047 * IMAGE_WIDTH, 0.9781021897810219 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.014018691588785047 * IMAGE_WIDTH, 0.8832116788321168 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.014018691588785047 * IMAGE_WIDTH, 0.7737226277372263 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY2.closePath();
                    final Area FRAME_MAIN_GLOSSY_2 = new Area(FRAME_MAIN_GLOSSY2);
                    FRAME_MAIN_GLOSSY_2.subtract(SUBTRACT);
                    G2.setPaint(new LinearGradientPaint(new Point2D.Double(0.5 * IMAGE_WIDTH, 0.0072992700729927005 * IMAGE_HEIGHT * VERTICAL_SCALE), new Point2D.Double(0.5000000000000001 * IMAGE_WIDTH, 1.0 * IMAGE_HEIGHT * VERTICAL_SCALE), new float[]{0.0f, 0.24f, 0.34f, 0.65f, 0.85f, 1.0f}, new Color[]{new Color(0.9764705882f, 0.9764705882f, 0.9764705882f, 1f), new Color(0.7843137255f, 0.7647058824f, 0.7490196078f, 1f), new Color(0.9882352941f, 0.9882352941f, 0.9882352941f, 1f), new Color(0.1215686275f, 0.1215686275f, 0.1215686275f, 1f), new Color(0.7843137255f, 0.7607843137f, 0.7529411765f, 1f), new Color(0.8156862745f, 0.8156862745f, 0.8156862745f, 1f)}));
                    G2.fill(FRAME_MAIN_GLOSSY_2);

                    final GeneralPath FRAME_MAIN_GLOSSY3 = new GeneralPath();
                    FRAME_MAIN_GLOSSY3.setWindingRule(Path2D.WIND_EVEN_ODD);
                    FRAME_MAIN_GLOSSY3.moveTo(0.07009345794392523 * IMAGE_WIDTH, 0.7737226277372263 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY3.curveTo(0.07009345794392523 * IMAGE_WIDTH, 0.39416058394160586 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.26635514018691586 * IMAGE_WIDTH, 0.10948905109489052 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.5 * IMAGE_WIDTH, 0.10948905109489052 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY3.curveTo(0.7289719626168224 * IMAGE_WIDTH, 0.10948905109489052 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.9252336448598131 * IMAGE_WIDTH, 0.38686131386861317 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.9252336448598131 * IMAGE_WIDTH, 0.7737226277372263 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY3.curveTo(0.9252336448598131 * IMAGE_WIDTH, 0.8102189781021898 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.9158878504672897 * IMAGE_WIDTH, 0.8905109489051095 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.9158878504672897 * IMAGE_WIDTH, 0.8905109489051095 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY3.lineTo(0.07476635514018691 * IMAGE_WIDTH, 0.8905109489051095 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY3.curveTo(0.07476635514018691 * IMAGE_WIDTH, 0.8905109489051095 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.07009345794392523 * IMAGE_WIDTH, 0.8102189781021898 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.07009345794392523 * IMAGE_WIDTH, 0.7737226277372263 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY3.closePath();
                    final Area FRAME_MAIN_GLOSSY_3 = new Area(FRAME_MAIN_GLOSSY3);
                    FRAME_MAIN_GLOSSY_3.subtract(SUBTRACT);
                    G2.setPaint(new Color(0.9647058824f, 0.9647058824f, 0.9647058824f, 1f));
                    G2.fill(FRAME_MAIN_GLOSSY_3);

                    final GeneralPath FRAME_MAIN_GLOSSY4 = new GeneralPath();
                    FRAME_MAIN_GLOSSY4.setWindingRule(Path2D.WIND_EVEN_ODD);
                    FRAME_MAIN_GLOSSY4.moveTo(0.07476635514018691 * IMAGE_WIDTH, 0.7737226277372263 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY4.curveTo(0.07476635514018691 * IMAGE_WIDTH, 0.41605839416058393 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.26635514018691586 * IMAGE_WIDTH, 0.11678832116788321 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.5 * IMAGE_WIDTH, 0.11678832116788321 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY4.curveTo(0.7289719626168224 * IMAGE_WIDTH, 0.11678832116788321 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.9205607476635514 * IMAGE_WIDTH, 0.41605839416058393 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.9205607476635514 * IMAGE_WIDTH, 0.7737226277372263 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY4.curveTo(0.9205607476635514 * IMAGE_WIDTH, 0.8102189781021898 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.9112149532710281 * IMAGE_WIDTH, 0.8832116788321168 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.9112149532710281 * IMAGE_WIDTH, 0.8832116788321168 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY4.lineTo(0.0794392523364486 * IMAGE_WIDTH, 0.8832116788321168 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY4.curveTo(0.0794392523364486 * IMAGE_WIDTH, 0.8832116788321168 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.07476635514018691 * IMAGE_WIDTH, 0.8102189781021898 * IMAGE_HEIGHT * VERTICAL_SCALE, 0.07476635514018691 * IMAGE_WIDTH, 0.7737226277372263 * IMAGE_HEIGHT * VERTICAL_SCALE);
                    FRAME_MAIN_GLOSSY4.closePath();
                    final Area FRAME_MAIN_GLOSSY_4 = new Area(FRAME_MAIN_GLOSSY4);
                    FRAME_MAIN_GLOSSY_4.subtract(SUBTRACT);
                    G2.setPaint(new Color(0.2f, 0.2f, 0.2f, 1f));
                    G2.fill(FRAME_MAIN_GLOSSY_4);
                    break;

                case BRASS:
                    float[] frameMainFractions5 = {
                        0.0f,
                        0.05f,
                        0.10f,
                        0.50f,
                        0.90f,
                        0.95f,
                        1.0f
                    };

                    Color[] frameMainColors5 = {
                        new Color(249, 243, 155, 255),
                        new Color(246, 226, 101, 255),
                        new Color(240, 225, 132, 255),
                        new Color(90, 57, 22, 255),
                        new Color(249, 237, 139, 255),
                        new Color(243, 226, 108, 255),
                        new Color(202, 182, 113, 255)
                    };
                    Util.INSTANCE.validateGradientPoints(FRAME_MAIN_START, FRAME_MAIN_STOP);
                    Paint frameMainGradient5 = new LinearGradientPaint(FRAME_MAIN_START, FRAME_MAIN_STOP, frameMainFractions5, frameMainColors5);
                    G2.setPaint(frameMainGradient5);
                    FRAME_MAIN_AREA.subtract(SUBTRACT);
                    G2.fill(FRAME_MAIN_AREA);
                    break;

                case STEEL:
                    float[] frameMainFractions6 = {
                        0.0f,
                        0.05f,
                        0.10f,
                        0.50f,
                        0.90f,
                        0.95f,
                        1.0f
                    };

                    Color[] frameMainColors6 = {
                        new Color(231, 237, 237, 255),
                        new Color(189, 199, 198, 255),
                        new Color(192, 201, 200, 255),
                        new Color(23, 31, 33, 255),
                        new Color(196, 205, 204, 255),
                        new Color(194, 204, 203, 255),
                        new Color(189, 201, 199, 255)
                    };
                    Util.INSTANCE.validateGradientPoints(FRAME_MAIN_START, FRAME_MAIN_STOP);
                    Paint frameMainGradient6 = new LinearGradientPaint(FRAME_MAIN_START, FRAME_MAIN_STOP, frameMainFractions6, frameMainColors6);
                    G2.setPaint(frameMainGradient6);
                    FRAME_MAIN_AREA.subtract(SUBTRACT);
                    G2.fill(FRAME_MAIN_AREA);
                    break;

                case CHROME:
                    float[] frameMainFractions7 = {
                        0.0f,
                        0.09f,
                        0.12f,
                        0.16f,
                        0.25f,
                        0.29f,
                        0.33f,
                        0.38f,
                        0.48f,
                        0.52f,
                        0.63f,
                        0.68f,
                        0.8f,
                        0.83f,
                        0.87f,
                        0.97f,
                        1.0f
                    };

                    Color[] frameMainColors7 = {
                        new Color(255, 255, 255, 255),
                        new Color(255, 255, 255, 255),
                        new Color(136, 136, 138, 255),
                        new Color(164, 185, 190, 255),
                        new Color(158, 179, 182, 255),
                        new Color(112, 112, 112, 255),
                        new Color(221, 227, 227, 255),
                        new Color(155, 176, 179, 255),
                        new Color(156, 176, 177, 255),
                        new Color(254, 255, 255, 255),
                        new Color(255, 255, 255, 255),
                        new Color(156, 180, 180, 255),
                        new Color(198, 209, 211, 255),
                        new Color(246, 248, 247, 255),
                        new Color(204, 216, 216, 255),
                        new Color(164, 188, 190, 255),
                        new Color(255, 255, 255, 255)
                    };

                    Paint frameMainGradient7 = new ConicalGradientPaint(false, FRAME_MAIN_CENTER, 0, frameMainFractions7, frameMainColors7);
                    G2.setPaint(frameMainGradient7);
                    FRAME_MAIN_AREA.subtract(SUBTRACT);
                    G2.fill(FRAME_MAIN_AREA);
                    break;

                case GOLD:
                    float[] frameMainFractions8 = {
                        0.0f,
                        0.15f,
                        0.22f,
                        0.3f,
                        0.38f,
                        0.44f,
                        0.51f,
                        0.6f,
                        0.68f,
                        0.75f,
                        1.0f
                    };

                    Color[] frameMainColors8 = {
                        new Color(255, 255, 207, 255),
                        new Color(255, 237, 96, 255),
                        new Color(254, 199, 57, 255),
                        new Color(255, 249, 203, 255),
                        new Color(255, 199, 64, 255),
                        new Color(252, 194, 60, 255),
                        new Color(255, 204, 59, 255),
                        new Color(213, 134, 29, 255),
                        new Color(255, 201, 56, 255),
                        new Color(212, 135, 29, 255),
                        new Color(247, 238, 101, 255)
                    };
                    Util.INSTANCE.validateGradientPoints(FRAME_MAIN_START, FRAME_MAIN_STOP);
                    Paint frameMainGradient8 = new LinearGradientPaint(FRAME_MAIN_START, FRAME_MAIN_STOP, frameMainFractions8, frameMainColors8);
                    G2.setPaint(frameMainGradient8);
                    FRAME_MAIN_AREA.subtract(SUBTRACT);
                    G2.fill(FRAME_MAIN_AREA);
                    break;

                case ANTHRACITE:
                    float[] frameMainFractions9 = {
                        0.0f,
                        0.06f,
                        0.12f,
                        1.0f
                    };
                    Color[] frameMainColors9 = {
                        new Color(118, 117, 135, 255),
                        new Color(74, 74, 82, 255),
                        new Color(50, 50, 54, 255),
                        new Color(97, 97, 108, 255)
                    };
                    Util.INSTANCE.validateGradientPoints(FRAME_MAIN_START, FRAME_MAIN_STOP);
                    Paint frameMainGradient9 = new LinearGradientPaint(FRAME_MAIN_START, FRAME_MAIN_STOP, frameMainFractions9, frameMainColors9);
                    G2.setPaint(frameMainGradient9);
                    FRAME_MAIN_AREA.subtract(SUBTRACT);
                    G2.fill(FRAME_MAIN_AREA);
                    break;

                case TILTED_GRAY:
                    FRAME_MAIN_START.setLocation((0.2336448598130841 * IMAGE_WIDTH), (0.08411214953271028 * IMAGE_HEIGHT));
                    FRAME_MAIN_STOP.setLocation(((0.2336448598130841 + 0.5789369637935792) * IMAGE_WIDTH), ((0.08411214953271028 + 0.8268076708711319) * IMAGE_HEIGHT));
                    float[] frameMainFractions10 = {
                        0.0f,
                        0.07f,
                        0.16f,
                        0.33f,
                        0.55f,
                        0.79f,
                        1.0f
                    };
                    Color[] frameMainColors10 = {
                        new Color(255, 255, 255, 255),
                        new Color(210, 210, 210, 255),
                        new Color(179, 179, 179, 255),
                        new Color(255, 255, 255, 255),
                        new Color(197, 197, 197, 255),
                        new Color(255, 255, 255, 255),
                        new Color(102, 102, 102, 255)
                    };
                    Util.INSTANCE.validateGradientPoints(FRAME_MAIN_START, FRAME_MAIN_STOP);
                    Paint frameMainGradient10 = new LinearGradientPaint(FRAME_MAIN_START, FRAME_MAIN_STOP, frameMainFractions10, frameMainColors10);
                    G2.setPaint(frameMainGradient10);
                    FRAME_MAIN_AREA.subtract(SUBTRACT);
                    G2.fill(FRAME_MAIN_AREA);
                    break;

                case TILTED_BLACK:
                    FRAME_MAIN_START.setLocation((0.22897196261682243 * IMAGE_WIDTH), (0.0794392523364486 * IMAGE_HEIGHT));
                    FRAME_MAIN_STOP.setLocation(((0.22897196261682243 + 0.573576436351046) * IMAGE_WIDTH), ((0.0794392523364486 + 0.8191520442889918) * IMAGE_HEIGHT));
                    float[] frameMainFractions11 = {
                        0.0f,
                        0.21f,
                        0.47f,
                        0.99f,
                        1.0f
                    };
                    Color[] frameMainColors11 = {
                        new Color(102, 102, 102, 255),
                        new Color(0, 0, 0, 255),
                        new Color(102, 102, 102, 255),
                        new Color(0, 0, 0, 255),
                        new Color(0, 0, 0, 255)
                    };
                    Util.INSTANCE.validateGradientPoints(FRAME_MAIN_START, FRAME_MAIN_STOP);
                    Paint frameMainGradient11 = new LinearGradientPaint(FRAME_MAIN_START, FRAME_MAIN_STOP, frameMainFractions11, frameMainColors11);
                    G2.setPaint(frameMainGradient11);
                    FRAME_MAIN_AREA.subtract(SUBTRACT);
                    G2.fill(FRAME_MAIN_AREA);
                    break;

                default:
                    float[] frameMainFractions = {
                        0.0f,
                        0.07f,
                        0.12f,
                        1.0f
                    };

                    Color[] frameMainColors = {
                        new Color(254, 254, 254, 255),
                        new Color(210, 210, 210, 255),
                        new Color(179, 179, 179, 255),
                        new Color(213, 213, 213, 255)
                    };
                    Util.INSTANCE.validateGradientPoints(FRAME_MAIN_START, FRAME_MAIN_STOP);
                    Paint frameMainGradient = new LinearGradientPaint(FRAME_MAIN_START, FRAME_MAIN_STOP, frameMainFractions, frameMainColors);
                    G2.setPaint(frameMainGradient);
                    FRAME_MAIN_AREA.subtract(SUBTRACT);
                    G2.fill(FRAME_MAIN_AREA);
                    break;
            }
        }

        final GeneralPath FRAME_INNERFRAME = new GeneralPath();
        FRAME_INNERFRAME.setWindingRule(Path2D.WIND_EVEN_ODD);
        FRAME_INNERFRAME.moveTo(IMAGE_WIDTH * 0.07906976744186046, IMAGE_HEIGHT * 0.7753623188405797 * VERTICAL_SCALE);
        FRAME_INNERFRAME.curveTo(IMAGE_WIDTH * 0.07906976744186046, IMAGE_HEIGHT * 0.41304347826086957 * VERTICAL_SCALE, IMAGE_WIDTH * 0.2651162790697674, IMAGE_HEIGHT * 0.12318840579710146 * VERTICAL_SCALE, IMAGE_WIDTH * 0.49767441860465117, IMAGE_HEIGHT * 0.12318840579710146 * VERTICAL_SCALE);
        FRAME_INNERFRAME.curveTo(IMAGE_WIDTH * 0.7302325581395349, IMAGE_HEIGHT * 0.12318840579710146 * VERTICAL_SCALE, IMAGE_WIDTH * 0.9162790697674419, IMAGE_HEIGHT * 0.41304347826086957 * VERTICAL_SCALE, IMAGE_WIDTH * 0.9162790697674419, IMAGE_HEIGHT * 0.7753623188405797 * VERTICAL_SCALE);
        FRAME_INNERFRAME.curveTo(IMAGE_WIDTH * 0.9162790697674419, IMAGE_HEIGHT * 0.8115942028985508 * VERTICAL_SCALE, IMAGE_WIDTH * 0.9069767441860465, IMAGE_HEIGHT * 0.8768115942028986 * VERTICAL_SCALE, IMAGE_WIDTH * 0.9069767441860465, IMAGE_HEIGHT * 0.8768115942028986 * VERTICAL_SCALE);
        FRAME_INNERFRAME.lineTo(IMAGE_WIDTH * 0.08837209302325581, IMAGE_HEIGHT * 0.8768115942028986 * VERTICAL_SCALE);
        FRAME_INNERFRAME.curveTo(IMAGE_WIDTH * 0.08837209302325581, IMAGE_HEIGHT * 0.8768115942028986 * VERTICAL_SCALE, IMAGE_WIDTH * 0.07906976744186046, IMAGE_HEIGHT * 0.8115942028985508 * VERTICAL_SCALE, IMAGE_WIDTH * 0.07906976744186046, IMAGE_HEIGHT * 0.7753623188405797 * VERTICAL_SCALE);
        FRAME_INNERFRAME.closePath();
        G2.setPaint(getInnerFrameColor());
        final Area FRAME_INNERFRAME_AREA = new Area(FRAME_INNERFRAME);
        FRAME_INNERFRAME_AREA.subtract(SUBTRACT);
        G2.fill(FRAME_INNERFRAME_AREA);

        // Apply frame effects
        final float[] EFFECT_FRACTIONS;
        final Color[] EFFECT_COLORS;
        final GradientWrapper EFFECT_GRADIENT;
        float scale = 1.0f;
        final java.awt.Shape[] EFFECT = new java.awt.Shape[100];
        switch (getFrameEffect()) {
            case EFFECT_BULGE:
                EFFECT_FRACTIONS = new float[]{
                    0.0f,
                    0.13f,
                    0.14f,
                    0.17f,
                    0.18f,
                    1.0f
                };
                EFFECT_COLORS = new Color[]{
                    new Color(0, 0, 0, 102),            // Outside
                    new Color(255, 255, 255, 151),
                    new Color(219, 219, 219, 153),
                    new Color(0, 0, 0, 95),
                    new Color(0, 0, 0, 76),       // Inside
                    new Color(0, 0, 0, 0)
                };
                EFFECT_GRADIENT = new GradientWrapper(new Point2D.Double(100, 0), new Point2D.Double(0, 0), EFFECT_FRACTIONS, EFFECT_COLORS);
                for (int i = 0; i < 100; i++) {
                    EFFECT[i] = Scaler.INSTANCE.scale(FRAME_MAIN_AREA, scale);
                    scale -= 0.01f;
                }
                G2.setStroke(new BasicStroke(1.5f));
                for (int i = 0; i < EFFECT.length; i++) {
                    G2.setPaint(EFFECT_GRADIENT.getColorAt(i / 100f));
                    G2.draw(EFFECT[i]);
                }
                break;

            case EFFECT_CONE:
                EFFECT_FRACTIONS = new float[]{
                    0.0f,
                    0.0399f,
                    0.04f,
                    0.1799f,
                    0.18f,
                    1.0f
                };
                EFFECT_COLORS = new Color[]{
                    new Color(0, 0, 0, 76),
                    new Color(223, 223, 223, 127),
                    new Color(255, 255, 255, 124),
                    new Color(9, 9, 9, 51),
                    new Color(0, 0, 0, 50),
                    new Color(0, 0, 0, 0)
                };
                EFFECT_GRADIENT = new GradientWrapper(new Point2D.Double(100, 0), new Point2D.Double(0, 0), EFFECT_FRACTIONS, EFFECT_COLORS);
                for (int i = 0; i < 100; i++) {
                    EFFECT[i] = Scaler.INSTANCE.scale(FRAME_MAIN_AREA, scale);
                    scale -= 0.01f;
                }
                G2.setStroke(new BasicStroke(1.5f));
                for (int i = 0; i < EFFECT.length; i++) {
                    G2.setPaint(EFFECT_GRADIENT.getColorAt(i / 100f));
                    G2.draw(EFFECT[i]);
                }
                break;

            case EFFECT_TORUS:
                EFFECT_FRACTIONS = new float[]{
                    0.0f,
                    0.08f,
                    0.1799f,
                    0.18f,
                    1.0f
                };
                EFFECT_COLORS = new Color[]{
                    new Color(0, 0, 0, 76),
                    new Color(255, 255, 255, 64),
                    new Color(13, 13, 13, 51),
                    new Color(0, 0, 0, 50),
                    new Color(0, 0, 0, 0)
                };
                EFFECT_GRADIENT = new GradientWrapper(new Point2D.Double(100, 0), new Point2D.Double(0, 0), EFFECT_FRACTIONS, EFFECT_COLORS);
                for (int i = 0; i < 100; i++) {
                    EFFECT[i] = Scaler.INSTANCE.scale(FRAME_MAIN_AREA, scale);
                    scale -= 0.01f;
                }
                G2.setStroke(new BasicStroke(1.5f));
                for (int i = 0; i < EFFECT.length; i++) {
                    G2.setPaint(EFFECT_GRADIENT.getColorAt(i / 100f));
                    G2.draw(EFFECT[i]);
                }
                break;

            case EFFECT_INNER_FRAME:
                final Shape EFFECT_BIGINNERFRAME = Scaler.INSTANCE.scale(FRAME_MAIN_AREA, 0.8785046339035034);
                final Point2D EFFECT_BIGINNERFRAME_START = new Point2D.Double(0, EFFECT_BIGINNERFRAME.getBounds2D().getMinY());
                final Point2D EFFECT_BIGINNERFRAME_STOP = new Point2D.Double(0, EFFECT_BIGINNERFRAME.getBounds2D().getMaxY());
                EFFECT_FRACTIONS = new float[]{
                    0.0f,
                    0.3f,
                    0.5f,
                    0.71f,
                    1.0f
                };
                EFFECT_COLORS = new Color[]{
                    new Color(0, 0, 0, 183),
                    new Color(148, 148, 148, 25),
                    new Color(0, 0, 0, 159),
                    new Color(0, 0, 0, 81),
                    new Color(255, 255, 255, 158)
                };
                Util.INSTANCE.validateGradientPoints(EFFECT_BIGINNERFRAME_START, EFFECT_BIGINNERFRAME_STOP);
                final LinearGradientPaint EFFECT_BIGINNERFRAME_GRADIENT = new LinearGradientPaint(EFFECT_BIGINNERFRAME_START, EFFECT_BIGINNERFRAME_STOP, EFFECT_FRACTIONS, EFFECT_COLORS);
                G2.setPaint(EFFECT_BIGINNERFRAME_GRADIENT);
                G2.fill(EFFECT_BIGINNERFRAME);
                break;
        }

        G2.dispose();

        return image;
    }
1165567
public static Graphics2D createGraphics(BufferedImage image, Color color) {
		return GraphicsUtil.createGraphics(image, color);
	}
179206
@Override
	public void getImageBytes(ByteBuffer buffer) {
		final BufferedImage bi = getImage();
		if (bi != null) {
			buffer.put(ImageUtils.imageToBytes(bi));
		}
	}
849934
private BufferedImage getImage(int layer) {
		BufferedImage image = layeredImage[layer];
		if (image == null) {
			createImageAndGraphics(layer);
			image = layeredImage[layer];
		}
		return image;
	}
1161559
public static boolean isKnownByteFormat( BufferedImage image ) {
		int type = image.getType();
		return type != BufferedImage.TYPE_BYTE_INDEXED &&
				type != BufferedImage.TYPE_BYTE_BINARY &&
				type != BufferedImage.TYPE_CUSTOM;
	}
882830
public static BufferedImage getImage(InputStream input) throws IOException
    {
        final BufferedImage buffer = ImageIO.read(input);
        if (buffer == null)
        {
            throw new IOException("Invalid image !");
        }
        return copyImage(buffer);
    }
364719
public static Image getInstance(byte imgb[]) throws BadElementException,
			MalformedURLException, IOException {
		InputStream is = null;
		try {
			is = new java.io.ByteArrayInputStream(imgb);
			int c1 = is.read();
			int c2 = is.read();
			int c3 = is.read();
			int c4 = is.read();
			is.close();

			is = null;
			if (c1 == 'G' && c2 == 'I' && c3 == 'F') {
				GifImage gif = new GifImage(imgb);
				return gif.getImage(1);
			}
			if (c1 == 0xFF && c2 == 0xD8) {
				return new Jpeg(imgb);
			}
			if (c1 == 0x00 && c2 == 0x00 && c3 == 0x00 && c4 == 0x0c) {
				return new Jpeg2000(imgb);
			}
			if (c1 == 0xff && c2 == 0x4f && c3 == 0xff && c4 == 0x51) {
				return new Jpeg2000(imgb);
			}
			if (c1 == PngImage.PNGID[0] && c2 == PngImage.PNGID[1]
					&& c3 == PngImage.PNGID[2] && c4 == PngImage.PNGID[3]) {
				return PngImage.getImage(imgb);
			}
			if (c1 == 0xD7 && c2 == 0xCD) {
				return new ImgWMF(imgb);
			}
			if (c1 == 'B' && c2 == 'M') {
				return BmpImage.getImage(imgb);
			}
			if ((c1 == 'M' && c2 == 'M' && c3 == 0 && c4 == 42)
					|| (c1 == 'I' && c2 == 'I' && c3 == 42 && c4 == 0)) {
				RandomAccessFileOrArray ra = null;
				try {
					ra = new RandomAccessFileOrArray(imgb);
					Image img = TiffImage.getTiffImage(ra, 1);
                    if (img.getOriginalData() == null)
                        img.setOriginalData(imgb);
					return img;
				} finally {
					if (ra != null)
						ra.close();
				}

			}
			if ( c1 == 0x97 && c2 == 'J' && c3 == 'B' && c4 == '2' ) {
				is = new java.io.ByteArrayInputStream(imgb);
				is.skip(4);
				int c5 = is.read();
				int c6 = is.read();
				int c7 = is.read();
				int c8 = is.read();
				if ( c5 == '\r' && c6 == '\n' && c7 == 0x1a && c8 == '\n' ) {
					int file_header_flags = is.read();
					@SuppressWarnings("unused")
					int number_of_pages = -1;
					if ( (file_header_flags & 0x2) == 0x2 ) {
						number_of_pages = (is.read() << 24) | (is.read() << 16) | (is.read() << 8) | is.read();
					}
					is.close();
					// a jbig2 file with a file header.  the header is the only way we know here.                                                           
					// embedded jbig2s don't have a header, have to create them by explicit use of Jbig2Image?
					// nkerr, 2008-12-05  see also the getInstance(URL)
					RandomAccessFileOrArray ra = null;
					try {
						ra = new RandomAccessFileOrArray(imgb);
						Image img = JBIG2Image.getJbig2Image(ra, 1);
						if (img.getOriginalData() == null)
							img.setOriginalData(imgb);
						return img;
					} finally {
						if (ra != null)
							ra.close();
					}
				}
			}
			throw new IOException(
					"The byte array is not a recognized imageformat.");
		} finally {
			if (is != null) {
				is.close();
			}
		}
	}
951588
public static Graphics2D createGraphics(BufferedImage image, Color color) {
		final Graphics2D g = image.createGraphics();
		// 填充背景
		g.setColor(color);
		g.fillRect(0, 0, image.getWidth(), image.getHeight());

		return g;
	}
968248
static BufferedImage convertImage (BufferedImage image) {
    switch (image.getType()) {
    case BufferedImage.TYPE_INT_ARGB_PRE:
      return image; // Already good to go
    case BufferedImage.TYPE_4BYTE_ABGR:
      image.coerceData(true); // Just premultiply the alpha and it's fine
      return image;
    }

    // Didn't know an easy thing to do, so create a whole new image in our preferred format
    BufferedImage convertedImage = new BufferedImage(image.getWidth(), image.getHeight(),
                                                     BufferedImage.TYPE_INT_ARGB_PRE);
    Graphics g = convertedImage.getGraphics();
    g.setColor(new Color(0f, 0f, 0f, 0f));
    g.fillRect(0, 0, image.getWidth(), image.getHeight());
    g.drawImage(image, 0, 0, null);

    return convertedImage;
  }
455134
public synchronized void setBufferedImage(BufferedImage image) {
		// assume the image was initially set before the GUI was invoked
		if( checkEventDispatch && this.img != null ) {
			if( !SwingUtilities.isEventDispatchThread() )
				throw new RuntimeException("Changed image when not in GUI thread?");
		}

		this.img = image;
		if( image != null )
			updateSize(image.getWidth(),image.getHeight());
	}