Examples of BufferedImage


Examples of ae.java.awt.image.BufferedImage

            return;
        }

        // BufferedImage case: use a simple drawImage call
        if (img instanceof BufferedImage) {
            BufferedImage bufImg = (BufferedImage)img;
            drawImage(bufImg,xform,null);
            return;
        }

        // transformState tracks the state of transform and
        // transX, transY contain the integer casts of the
        // translation factors
        boolean isIntegerTranslate =
            (transformState <= TRANSFORM_INT_TRANSLATE) &&
            isIntegerTranslation(xform);

        // Include padding for interpolation/antialiasing if necessary
        int pad = isIntegerTranslate ? 0 : 3;

        // Determine the region of the image that may contribute to
        // the clipped drawing area
        Rectangle region = getImageRegion(img,
                                          getCompClip(),
                                          transform,
                                          xform,
                                          pad, pad);
        if (region.width <= 0 || region.height <= 0) {
            return;
        }

        // Attempt to optimize integer translation of tiled images.
        // Although theoretically we are O.K. if the concatenation of
        // the user transform and the device transform is an integer
        // translation, we'll play it safe and only optimize the case
        // where both are integer translations.
        if (isIntegerTranslate) {
            // Use optimized code
            // Note that drawTranslatedRenderedImage calls copyImage
            // which takes the user space to device space transform into
            // account, but we need to provide the image space to user space
            // translations.

            drawTranslatedRenderedImage(img, region,
                                        (int) xform.getTranslateX(),
                                        (int) xform.getTranslateY());
            return;
        }

        // General case: cobble the necessary region into a single Raster
        Raster raster = img.getData(region);

        // Make a new Raster with the same contents as raster
        // but starting at (0, 0).  This raster is thus in the same
        // coordinate system as the SampleModel of the original raster.
        WritableRaster wRaster =
              Raster.createWritableRaster(raster.getSampleModel(),
                                          raster.getDataBuffer(),
                                          null);

        // If the original raster was in a different coordinate
        // system than its SampleModel, we need to perform an
        // additional translation in order to get the (minX, minY)
        // pixel of raster to be pixel (0, 0) of wRaster.  We also
        // have to have the correct width and height.
        int minX = raster.getMinX();
        int minY = raster.getMinY();
        int width = raster.getWidth();
        int height = raster.getHeight();
        int px = minX - raster.getSampleModelTranslateX();
        int py = minY - raster.getSampleModelTranslateY();
        if (px != 0 || py != 0 || width != wRaster.getWidth() ||
            height != wRaster.getHeight()) {
            wRaster =
                wRaster.createWritableChild(px,
                                            py,
                                            width,
                                            height,
                                            0, 0,
                                            null);
        }

        // Now we have a BufferedImage starting at (0, 0)
        // with the same contents that started at (minX, minY)
        // in raster.  So we must draw the BufferedImage with a
        // translation of (minX, minY).
        AffineTransform transXform = (AffineTransform)xform.clone();
        transXform.translate(minX, minY);

        ColorModel cm = img.getColorModel();
        BufferedImage bufImg = new BufferedImage(cm,
                                                 wRaster,
                                                 cm.isAlphaPremultiplied(),
                                                 null);
        drawImage(bufImg, transXform, null);
    }
View Full Code Here

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

     */
    protected void fill(Shape shape, Paint paint) {
        Rectangle2D bounds = shape.getBounds2D();

        // create image
        BufferedImage image = new BufferedImage(
            (int)Math.ceil(bounds.getWidth()) + 1,
            (int)Math.ceil(bounds.getHeight()) + 1,
            BufferedImage.TYPE_INT_ARGB);

        // fill background
        Graphics2D graphics = image.createGraphics();
        graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
        graphics.fill(graphics.getDeviceConfiguration().getBounds());
        graphics.setComposite(AlphaComposite.SrcOver);

        // draw paint
View Full Code Here

Examples of com.jgraph.gaeawt.java.awt.image.BufferedImage

{
  public static BufferedImage clipImageTest() throws IOException, ImageReadException
  {
    int w = 600;
    int h = 600;
    BufferedImage imageARGB = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    String filename = "Venus of Urbino.jpg";
    InputStream in = ClipImage.class.getResourceAsStream(filename);
    final BufferedImage image = Sanselan.getBufferedImage(in);
    in.close();

    Graphics2D g2 = imageARGB.createGraphics();
    g2.rotate(-Math.PI / 12, image.getWidth() / 2, image.getHeight() / 2);
    String s = "bella";
    Font font = new Font("Serif", Font.PLAIN, 192);
    FontRenderContext frc = g2.getFontRenderContext();
    //GlyphVector gv = font.createGlyphVector(frc, s);
    //Shape clippingShape = gv.getOutline(10, 200);
View Full Code Here

Examples of java.awt.image.BufferedImage

            if(new File("imgs/TrayIcon.png").isFile()) {
              mTrayIcon = new TrayIcon(ImageIO.read(new File("imgs/TrayIcon.png")), tooltip);
            }
            else {
              Dimension trayIconSize = getTrayIconSize();
              BufferedImage trayIconImage = null;
              Color backgroundColor = null;

              if(trayIconSize.height > 16 && trayIconSize.height <= 32 && new File("imgs/tvbrowser32.png").isFile()) {
                trayIconImage = UiUtilities.scaleIconToBufferedImage(ImageIO.read(new File("imgs/tvbrowser32.png")),
                    trayIconSize.width, trayIconSize.height, BufferedImage.TYPE_INT_ARGB, backgroundColor);
View Full Code Here

Examples of java.awt.image.BufferedImage

        response.getOutputStream().write(buffer);
        response.getOutputStream().flush();
        response.getOutputStream().close();
      } else {

        BufferedImage image = ImageIO.read(tfile);

        BufferedImage myImage =
          new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
        Graphics g = myImage.getGraphics();
        g.setColor(Color.WHITE);
        g.fillRect(0, 0, w, h);

        int width = image.getWidth();
        int height = image.getHeight();
View Full Code Here

Examples of java.awt.image.BufferedImage

           int levelThreshold = MAX_TREE_DEPTH;
           // create a BufferedImage of only 1 pixel height for fetching the rows
           // of the image in the correct format (ARGB)
           // This speeds up things by more than factor 2, compared to the standard
           // BufferedImage.getRGB solution
           BufferedImage row = new BufferedImage(width, 1, BufferedImage.TYPE_INT_ARGB);
           Graphics2D g2d = row.createGraphics();
           int pixels[] = ((DataBufferInt) row.getRaster().getDataBuffer()).getData();
           // make sure alpha values do not add up for each row:
           g2d.setComposite(AlphaComposite.Src);
           // calculate scanline by scanline in order to safe memory.
           // It also seems to run faster like that
           for (y = 0; y < height; y++) {
View Full Code Here

Examples of java.awt.image.BufferedImage

           } else {
               icm = new IndexColorModel(depth, numColors, colorMap[0], colorMap[1], colorMap[2], colorMap[3]);
           }

           // create the indexed BufferedImage:
           BufferedImage dest = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_INDEXED, icm);

           if (dither)
               new DiffusionFilterOp().filter(image, dest);
           else {
               ClosestColor closest = new ClosestColor();
               // convert to indexed color
               byte[] dst = ((DataBufferByte) dest.getRaster().getDataBuffer()).getData();

               // create a BufferedImage of only 1 pixel height for fetching
               // the rows of the image in the correct format (ARGB)
               // This speeds up things by more than factor 2, compared to the
               // standard BufferedImage.getRGB solution
               BufferedImage row = new BufferedImage(width, 1, BufferedImage.TYPE_INT_ARGB);
               Graphics2D g2d = row.createGraphics();
               int pixels[] = ((DataBufferInt) row.getRaster().getDataBuffer()).getData();
               // make sure alpha values do not add up for each row:
               g2d.setComposite(AlphaComposite.Src);
               // calculate scanline by scanline in order to safe memory.
               // It also seems to run faster like that
               Node node;
View Full Code Here

Examples of java.awt.image.BufferedImage

   * @throws IOException
   */
  protected boolean rotate(HttpContext ctx, String imgURL, int orient) throws IOException{
    PhotoSaver saver = this.getPhotoSaver();
    InputStream inImg = saver.read(ctx, imgURL);
    BufferedImage old_img = (BufferedImage)ImageIO.read(inImg)
    int width = old_img.getWidth();
    int height = old_img.getHeight();
    BufferedImage new_img = new BufferedImage(height,width,BufferedImage.TYPE_INT_RGB);       
        Graphics2D g2d =new_img.createGraphics();
       
        AffineTransform origXform = g2d.getTransform();
        AffineTransform newXform = (AffineTransform)(origXform.clone());
        // center of rotation is center of the panel
    double radian = 0;
View Full Code Here

Examples of java.awt.image.BufferedImage

     
    }
  }
 
  private static WritableRenderedImage toImage(RgbImage rgb) {
    WritableRenderedImage im = new BufferedImage(
        rgb.getWidth(),
        rgb.getHeight(),
        BufferedImage.TYPE_INT_RGB);
    DataBufferInt dbi = new DataBufferInt(
        rgb.getData(),
        rgb.getHeight() * rgb.getWidth());
    Raster r = Raster.createRaster(
        im.getSampleModel(),
        dbi,
        null);
    im.setData(r);
    return im;
  }
View Full Code Here

Examples of java.awt.image.BufferedImage

    }
   
    //��ȡͼƬ�Ļ�����Ϣ�������С�ߴ����ص�
    File fOrigionalImage = new File(origionalPath);
    photo.setSize((int)fOrigionalImage.length());
    BufferedImage oldImage = (BufferedImage)ImageIO.read(fOrigionalImage);
    int old_width = oldImage.getWidth();
    int old_height = oldImage.getHeight();
    photo.setWidth(old_width);
    photo.setHeight(old_height);
    photo.setColorBit(oldImage.getColorModel().getPixelSize());
    photo.setFileName(imgFile.getFileName());
   
    {
      //��ԭͼƬ�޶���1024*768�ķ�Χ��
      int ori_width = MAX_WIDTH, ori_height = MAX_HEIGHT;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.