Package java.awt.image

Examples of java.awt.image.BufferedImage


    public static byte[] getBytes(DcImageIcon icon, int type) {
        return getBytes(icon.getImage(), type);
    }
   
    public static byte[] getBytes(Image image, int type) {
      BufferedImage bi;
      if (image instanceof BufferedImage)
        bi = (BufferedImage) image;
      else
        bi = Utilities.toBufferedImage(new DcImageIcon(image), -1, -1);
     
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        BufferedOutputStream bos = new BufferedOutputStream(baos);
       
        byte[] bytes = null;
        try {
            ImageIO.write(bi, (type == DcImageIcon._TYPE_JPEG ? "JPG" : "PNG"), bos);
            bos.flush();
            bytes = baos.toByteArray();
            bi.flush();
        } catch (IOException e) {
            logger.error(e, e);
        }
       
        try {
View Full Code Here


    public static void writeScaledImageToFile(DcImageIcon icon, File file) throws Exception {
      writeScaledImageToFile(icon, file, DcImageIcon._TYPE_PNG, 190, 145);
    }

    public static void writeScaledImageToFile(DcImageIcon icon, File file, int type, int w, int h) throws Exception {
        BufferedImage bufferedImage = toBufferedImage(icon, w, h);
        ImageIO.write(bufferedImage, (type == DcImageIcon._TYPE_JPEG ? "JPG" : "PNG"), file);
        bufferedImage.flush();
    }      
View Full Code Here

                h = (int) (w / imageRatio);
            else
                w = (int) (h * imageRatio);
        }
       
        BufferedImage bi = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT);
       
        Graphics g = bi.createGraphics();
        DcSwingUtilities.setRenderingHint(g);
        g.drawImage(image, 0, 0, w, h, null);
        g.dispose();
       
        bi.flush();
//        image.flush();
       
        return bi;
    }
View Full Code Here

        TexturePaint texture = null;
        try {

            if (fillPatternURL != null) {
                BufferedImage bi = BufferedImageHelper.getBufferedImage(fillPatternURL,
                        0,
                        0,
                        -1,
                        -1);
                texture = new TexturePaint(bi, new Rectangle(0, 0, bi.getWidth(), bi.getHeight()));
            }
        } catch (InterruptedException ie) {
            Debug.error("PoliticalArea.setFillPattern(): error getting texture image - \n"
                    + ie);
        }
View Full Code Here

                        imageURLString = (String) record.get(urlIndex);

                        URL imageURL = PropUtils.getResourceOrFileOrURL(imageURLString);

                        FileCacheImageInputStream fciis = new FileCacheImageInputStream(imageURL.openStream(), null);
                        BufferedImage fileImage = ImageIO.read(fciis);

                        // ImageIcon ii = new ImageIcon(imageURL);
                        // Image fileImage = ii.getImage();

                        // try {
View Full Code Here

     *
     * @param object
     */
    private void initMetrics() {
        if (g2D == null)
            g2D = (Graphics2D) new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB).getGraphics();
        if (font == null)
            font = g2D.getFont();
        metrics = g2D.getFontMetrics(font);
    }
View Full Code Here

                    // Debug.output("OMRaster.generate: length(pixels)
                    // = " +
                    // pixels.length);
                }

                bitmap = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
                // ((BufferedImage) bitmap).setRGB(0,
                // 0,
                // width,
                // height,
                // pixels,
View Full Code Here

        try {
            SVGRasterizer svgr;
            svgr = new SVGRasterizer(file.toURL());
            svgr.setBackgroundColor(new Color(128, 128, 128, 0));
            BufferedImage bi = svgr.createBufferedImage(imageDimension);
            byte[] imageBytes = formatter.formatImage(bi);

            String newFileName = file.toString().replaceAll(".svg", ".gif");
            if (Debug.debugging("svg")) {
                Debug.output("writing " + newFileName + " from " + file);
View Full Code Here

            String fileName = FileUtils.getFilePathToOpenFromUser("Locate SVG File");
            URL fileURL = PropUtils.getResourceOrFileOrURL(fileName);

            SVGRasterizer svgr = new SVGRasterizer(fileURL);
            svgr.setBackgroundColor(OMColor.clear);
            BufferedImage bi = svgr.createBufferedImage();

            JFrame frame = new JFrame();
            frame.addWindowListener(new WindowAdapter() {
                public void windowClosed(WindowEvent e) {
                    System.exit(0);
View Full Code Here

        } catch (IllegalArgumentException iae) {
            // Not an image file, punch
            Debug.error("EditableOMScalingRaster:  " + pathToFile
                    + " doesn't appear to be an image file");
            raster = new OMScalingRaster(90f, -180f, 89f, -179f, new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB));
        }

        if (ga != null) {
            ga.setTo(raster, true);
        }
View Full Code Here

TOP

Related Classes of java.awt.image.BufferedImage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.