Package java.awt.image

Examples of java.awt.image.BufferedImage


   * @param ic
   * @return ImageIcon
   * @since 2.1
   */
  public static ImageIcon createChannelIcon(Icon ic) {
    BufferedImage img = new BufferedImage(getChannelIconWidth(), getChannelIconHeight(), BufferedImage.TYPE_INT_RGB);

    if (ic == null) {
      ic = new ImageIcon("./imgs/tvbrowser16.png");
    }

    int height = 20;
    int width = 40;

    if ((ic.getIconWidth() != 0) && (ic.getIconHeight() != 0)) {
      double iWidth = ic.getIconWidth();
      double iHeight = ic.getIconHeight();
      if (iWidth / iHeight < 2.0) {
        width = (int) (iWidth * (20.0 / iHeight));
      } else {
        height = (int) (iHeight * (40.0 / iWidth));
      }
    }
    ic = scaleIcon(ic, width, height);

    Graphics2D g = img.createGraphics();

    g.setColor(Color.WHITE);
    g.fillRect(1, 1, 40, 20);

    int x = 1 + 20 - ic.getIconWidth() / 2;
View Full Code Here


    /**
     * Create a small Icon with the current Color
     * @return Icon with Color
     */
    private Icon createIcon() {
        BufferedImage img = new BufferedImage(50, 10, BufferedImage.TYPE_INT_RGB);
       
        Graphics2D g = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(img);
       
        g.setColor(Color.WHITE);
        g.fillRect(0,0,50,10);
View Full Code Here

                outname = fileName + ".jpg";
            }
            RenderedOp img = JAI.create("fileload", fileName);
            ColorModel cm = img.getColorModel();
            WritableRaster imgRaster = img.copyData();
            BufferedImage bi = new BufferedImage(cm, imgRaster, false, new Hashtable());
            ImageIO.write((RenderedImage) bi, "jpg", new File(outname));
            System.out.println("...done, " + outname);
        } catch (Exception e) {
            e.printStackTrace();
        }
View Full Code Here

   */
  public static Image getInstance(java.awt.Image image, java.awt.Color color,
      boolean forceBW) throws BadElementException, IOException {
   
    if(image instanceof BufferedImage){
      BufferedImage bi = (BufferedImage) image;
      if(bi.getType()==BufferedImage.TYPE_BYTE_BINARY) {
        forceBW=true;
      }
    }
   
    java.awt.image.PixelGrabber pg = new java.awt.image.PixelGrabber(image,
View Full Code Here

     * @param cssWidth  Target width for the element.
     * @param cssHeight Target height for the element
     * @return A ReplacedElement to substitute for one that can't be generated.
     */
    protected ReplacedElement newIrreplaceableImageElement(int cssWidth, int cssHeight) {
        BufferedImage missingImage = null;
        ReplacedElement mre;
        try {
            // TODO: we can come up with something better; not sure if we should use Alt text, how text should size, etc.
            missingImage = ImageUtil.createCompatibleBufferedImage(cssWidth, cssHeight, BufferedImage.TYPE_INT_RGB);
            Graphics2D g = missingImage.createGraphics();
            g.setColor(Color.BLACK);
            g.setBackground(Color.WHITE);
            g.setFont(new Font("Serif", Font.PLAIN, 12));
            g.drawString("Missing", 0, 12);
            g.dispose();
View Full Code Here

        //TODO: check that cached image is still valid
        if (ir == null) {
            InputStream is = resolveAndOpenStream(uri);
            if (is != null) {
                try {
                    BufferedImage img = ImageIO.read(is);
                    if (img == null) {
                        throw new IOException("ImageIO.read() returned null");
                    }
                    ir = createImageResource(uri, img);
                    _imageCache.put(uri, ir);
View Full Code Here

        fis.close(); fis = null;
        GifImage newGif = GifTransformer.resize(gifImage, p_width,p_height, false);
        newimage = new FileOutputStream(obj_filename);
        GifEncoder.encode(newGif, newimage);
      } else {
        BufferedImage orig_portrait = (BufferedImage) ImageIO.read(fis);
        fis.close(); fis = null;
        // ͳһת��JPG��ʽ
        BufferedImage bi = new BufferedImage(p_width, p_height,BufferedImage.TYPE_INT_RGB);
        bi.getGraphics().drawImage(orig_portrait, 0, 0, p_width,p_height, null);
        if(!obj_filename.endsWith(".jpg"))
          obj_filename += ".jpg";
        newimage = new FileOutputStream(obj_filename);
        ImageIO.write(bi, "jpg", newimage);
      }
View Full Code Here

      radian = 270.0;
      break;
    default:
      return false;
    }
    BufferedImage old_img = (BufferedImage)ImageIO.read(new File(img_fn))
    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 xRot = 0;
View Full Code Here

    return s_fn.endsWith("bmp");
  }
 
  public static String BMP_TO_JPG(String imgPath) throws IOException{
    File fOrigionalImage = new File(imgPath);
    BufferedImage oldImage = (BufferedImage)ImageIO.read(fOrigionalImage);
    String jpgName = imgPath+".jpg";
    FileOutputStream newimage = new FileOutputStream(jpgName);
    try{
      if(ImageIO.write(oldImage, "jpg", newimage))
        return jpgName;
View Full Code Here

      setDocument(loadDocument(sourceDocument), sourceDocumentBase, new XhtmlNamespaceHandler());

      layout(this.width);

      height = this.height == -1 ? root.getHeight() : this.height;
      BufferedImage outputImage = createBufferedImage(this.width, height);
      outputDevice = new Java2DOutputDevice(outputImage);
      Graphics2D newG = (Graphics2D) outputImage.getGraphics();
      if ( renderingHints != null ) {
        newG.getRenderingHints().putAll(renderingHints);
      }

      RenderingContext rc = sharedContext.newRenderingContextInstance();
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.