Package com.google.code.appengine.awt.image

Examples of com.google.code.appengine.awt.image.BufferedImage


        WritableRaster r =
                dstCM.isCompatibleSampleModel(src.getSampleModel()) ?
                src.getRaster().createCompatibleWritableRaster(src.getWidth(), src.getHeight()) :
                dstCM.createCompatibleWritableRaster(src.getWidth(), src.getHeight());

        return new BufferedImage(
                dstCM,
                r,
                dstCM.isAlphaPremultiplied(),
                null
        );
View Full Code Here


            // awt.25A=Source equals to destination
            throw new IllegalArgumentException(Messages.getString("awt.25A")); //$NON-NLS-1$
        }

        ColorModel srcCM = src.getColorModel();
        BufferedImage finalDst = null;

        if (srcCM instanceof IndexColorModel) {
            src = ((IndexColorModel)srcCM).convertToIntDiscrete(src.getRaster(), true);
            srcCM = src.getColorModel();
        }

        if (dst == null) {
            dst = createCompatibleDestImage(src, srcCM);
        } else {
            if (!srcCM.equals(dst.getColorModel())) {
                // Treat BufferedImage.TYPE_INT_RGB and BufferedImage.TYPE_INT_ARGB as same
                if (
                        !((src.getType() == BufferedImage.TYPE_INT_RGB ||
                           src.getType() == BufferedImage.TYPE_INT_ARGB) &&
                          (dst.getType() == BufferedImage.TYPE_INT_RGB ||
                           dst.getType() == BufferedImage.TYPE_INT_ARGB))
                ) {
                    finalDst = dst;
                    dst = createCompatibleDestImage(src, srcCM);
                }
            }
        }

        // Skip alpha channel for TYPE_INT_RGB images
        // TODO
        //if (ippFilter(src.getRaster(), dst.getRaster(), src.getType()) != 0)
            if (slowFilter(src.getRaster(), dst.getRaster()) != 0) {
                // awt.21F=Unable to transform source
                throw new ImagingOpException (Messages.getString("awt.21F")); //$NON-NLS-1$
            }

        if (finalDst != null) {
            Graphics2D g = finalDst.createGraphics();
            g.setComposite(AlphaComposite.Src);
            g.drawImage(dst, 0, 0, null);
        } else {
            finalDst = dst;
        }
View Full Code Here

   * @throws ChartDataException
   * @throws PropertyException
   *******************************************************************************************/
  public void renderWithImageMap() throws ChartDataException, PropertyException
  {
    this.bufferedImage = new BufferedImage( this.getImageWidth(), this.getImageHeight(), BufferedImage.TYPE_INT_RGB );
    this.setGraphics2D( this.bufferedImage.createGraphics() );
    this.generateImageMap = true;

    this.render();
  }
View Full Code Here

   * @throws PropertyException
   * @throws IOException
   *******************************************************************************************/
  public static void encode( Chart chart, OutputStream outputStream ) throws ChartDataException, PropertyException, IOException
  {
    BufferedImage bufferedImage = BinaryEncoderUtil.render( chart );
    ImageIO.write( bufferedImage, PNG, outputStream );
  }
View Full Code Here

   * @throws ChartDataException
   * @throws PropertyException
   *******************************************************************************************/
  static BufferedImage render( Chart chart ) throws ChartDataException, PropertyException
  {
    BufferedImage bufferedImage = null;

    //---if we use an ImageMap, we already have rendered the chart byt the time we get here so,
    //---  simply return the rendered image.
    if( chart.getGenerateImageMapFlag() )
    {
      bufferedImage = chart.getBufferedImage();
    }
    //---else, create a new BufferedImage and set the Graphics2D onto the chart.
    else
    {
      bufferedImage = new BufferedImage( chart.getImageWidth(), chart.getImageHeight(), BufferedImage.TYPE_INT_RGB );
      chart.setGraphics2D( bufferedImage.createGraphics() );
      chart.render();
    }

    return bufferedImage;
  }
View Full Code Here

   *******************************************************************************************/
  public static void encode( Chart chart,
                    float quality,
                    OutputStream outputStream ) throws ChartDataException, PropertyException, IOException
  {
    BufferedImage bufferedImage = BinaryEncoderUtil.render( chart );

    Iterator writers = ImageIO.getImageWritersByFormatName( JPEG );
    ImageWriter imageWriter = (ImageWriter) writers.next();

    JPEGImageWriteParam params = new JPEGImageWriteParam( null );
View Full Code Here

        WritableRaster r =
                dstCM.isCompatibleSampleModel(src.getSampleModel()) ?
                src.getRaster().createCompatibleWritableRaster(src.getWidth(), src.getHeight()) :
                dstCM.createCompatibleWritableRaster(src.getWidth(), src.getHeight());

        return new BufferedImage(
                dstCM,
                r,
                dstCM.isAlphaPremultiplied(),
                null
        );
View Full Code Here

        } else {
            // awt.229=Number of components in the LUT does not match the number of bands
            throw new IllegalArgumentException(Messages.getString("awt.229")); //$NON-NLS-1$
        }

        BufferedImage finalDst = null;
        if (dst == null) {
            dst = createCompatibleDestImage(src, null);
        } else {
            if (src.getWidth() != dst.getWidth()){
                throw new IllegalArgumentException(Messages.getString("awt.291")); //$NON-NLS-1$
            }

            if (src.getHeight() != dst.getHeight()){
                throw new IllegalArgumentException(Messages.getString("awt.292")); //$NON-NLS-1$
            }

            if (!srcCM.equals(dst.getColorModel())) {
                // Treat BufferedImage.TYPE_INT_RGB and
                // BufferedImage.TYPE_INT_ARGB as same
                if (!((src.getType() == BufferedImage.TYPE_INT_RGB || src
                        .getType() == BufferedImage.TYPE_INT_ARGB) && (dst
                        .getType() == BufferedImage.TYPE_INT_RGB || dst
                        .getType() == BufferedImage.TYPE_INT_ARGB))) {
                    finalDst = dst;
                    dst = createCompatibleDestImage(src, null);
                }
            }
        }

        // TODO
        //if (!canUseIpp || ippFilter(src.getRaster(), dst.getRaster(), src.getType(), skipAlpha) != 0)
            if (slowFilter(src.getRaster(), dst.getRaster(), skipAlpha) != 0) {
                // awt.21F=Unable to transform source
                throw new ImagingOpException (Messages.getString("awt.21F")); //$NON-NLS-1$
            }

        if (finalDst != null) {
            Graphics2D g = finalDst.createGraphics();
            g.setComposite(AlphaComposite.Src);
            g.drawImage(dst, 0, 0, null);
        } else {
            finalDst = dst;
        }
View Full Code Here

            throw new RasterFormatException(
                    Messages.getString("awt.251", dstWidth, dstHeight)); //$NON-NLS-1$
        }

        if (destCM != null) {
            return new BufferedImage(destCM,
                    destCM.createCompatibleWritableRaster((int)dstWidth, (int)dstHeight),
                    destCM.isAlphaPremultiplied(),
                    null
            );
        }

        ColorModel cm = src.getColorModel();

        // Interpolation other than NN doesn't make any sense for index color
        if (iType != TYPE_NEAREST_NEIGHBOR && cm instanceof IndexColorModel) {
            return new BufferedImage((int)dstWidth, (int)dstHeight, BufferedImage.TYPE_INT_ARGB);
        }

        // OK, we can get source color model
        return new BufferedImage(cm,
                src.getRaster().createCompatibleWritableRaster((int)dstWidth, (int)dstHeight),
                cm.isAlphaPremultiplied(),
                null
        );
    }
View Full Code Here

            // awt.252=Source can't be same as the destination
            throw new IllegalArgumentException(Messages.getString("awt.252")); //$NON-NLS-1$
        }

        ColorModel srcCM = src.getColorModel();
        BufferedImage finalDst = null;

        if (
                srcCM instanceof IndexColorModel &&
                (iType != TYPE_NEAREST_NEIGHBOR || srcCM.getPixelSize() % 8 != 0)
        ) {
            src = ((IndexColorModel)srcCM).convertToIntDiscrete(src.getRaster(), true);
            srcCM = src.getColorModel();
        }

        if (dst == null) {
            dst = createCompatibleDestImage(src, srcCM);
        } else {
            if (!srcCM.equals(dst.getColorModel())) {
                // Treat BufferedImage.TYPE_INT_RGB and BufferedImage.TYPE_INT_ARGB as same
                if (
                   !(
                     (src.getType() == BufferedImage.TYPE_INT_RGB ||
                      src.getType() == BufferedImage.TYPE_INT_ARGB) &&
                     (dst.getType() == BufferedImage.TYPE_INT_RGB ||
                      dst.getType() == BufferedImage.TYPE_INT_ARGB)
                    )
                ) {
                    finalDst = dst;
                    dst = createCompatibleDestImage(src, srcCM);
                }
            }
        }

        // Skip alpha channel for TYPE_INT_RGB images
        if (slowFilter(src.getRaster(), dst.getRaster()) != 0) {
            // awt.21F=Unable to transform source
            throw new ImagingOpException (Messages.getString("awt.21F")); //$NON-NLS-1$
        // TODO - uncomment
        //if (ippFilter(src.getRaster(), dst.getRaster(), src.getType()) != 0)
            //throw new ImagingOpException ("Unable to transform source");
        }

        if (finalDst != null) {
            Graphics2D g = finalDst.createGraphics();
            g.setComposite(AlphaComposite.Src);
            g.drawImage(dst, 0, 0, null);
        } else {
            finalDst = dst;
        }
View Full Code Here

TOP

Related Classes of com.google.code.appengine.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.