Package railo.runtime.img

Examples of railo.runtime.img.Image


      String[] strSrcs=ListUtil.listToStringArray(_srcs, ',');
      Resource[] srcs=new Resource[strSrcs.length];
      Image[] images=new Image[strSrcs.length];
      for(int i=0;i<srcs.length;i++){
        srcs[i]=ResourceUtil.toResourceExisting(pageContext, strSrcs[i]);
        images[i] = new Image(srcs[i]);
      }
     
      // TODO use the same resource as for cfimage
      PageSource ps = pageContext.getCurrentTemplatePageSource();
      Resource curr = ps.getResource();
      Resource dir = curr.getParentResource();
      Resource cssDir = dir.getRealResource("css");
      Resource pathdir = cssDir;
      cssDir.mkdirs();
     
     
      //the base name for the files we are going to create as a css and image
      String baseRenderedFileName = MD5.getDigestAsString(_ids);
      Resource cssFileName = cssDir.getRealResource(baseRenderedFileName+".css");
      Resource imgFileName = pathdir.getRealResource(baseRenderedFileName+"."+ResourceUtil.getExtension(src,""));
     
      //if the files don't exist, then we create them, otherwise
      boolean bCreate = !cssFileName.isFile() || !imgFileName.isFile();
     
     
      //Are we going to create it, let's say no
      String css = "";
      if(bCreate){
        int imgMaxHeight = 0;
        int imgMaxWidth = 0;
        Image img;
        int actualWidth,actualHeight;
        //Setup the max height and width of the new image.
        for(int i=0;i<srcs.length;i++){
          img = images[i];
         
          //set the image original height and width
          actualWidth = img.getWidth();;
          actualHeight = img.getHeight();
                 
                 
         
          //Check if there is a height,
          imgMaxHeight += actualHeight;
          if(actualWidth  > imgMaxWidth) imgMaxWidth  =  actualWidth;
        }
       
        //Create the new image (hence we needed to do two of these items)
        Image spriteImage = (Image) ImageNew.call(pageContext,"", ""+imgMaxWidth,""+imgMaxHeight, "argb");
       
        int placedHeight = 0;
        //Loop again but this time, lets do the copy and paste
        for(int i=0;i<srcs.length;i++){
          img = images[i];
          spriteImage.paste(img,1,placedHeight);
         
            css += "#"+ids[i]+" {\n\tbackground: url("+baseRenderedFileName+"."+ResourceUtil.getExtension(strSrcs[i],"")+") 0px -"+placedHeight+"px no-repeat; width:"+img.getWidth()+"px; height:"+img.getHeight()+"px;\n} \n";
            placedHeight += img.getHeight();
        }
       
View Full Code Here


  private void copy(OutputStream os, JFreeChart jfc, ChartRenderingInfo info) throws ApplicationException, IOException, ExpressionException {
    //OutputStream os = null;
    try {
      //os = res.getOutputStream();
      BufferedImage bi = jfc.createBufferedImage(chartwidth,chartheight,info);
      Image img;
     
      // add border
      if(showborder) {
        try {
          img = new Image(bi);
          img.addBorder(1,Color.BLACK,Image.BORDER_TYPE_CONSTANT);
          bi=img.getBufferedImage();
        }
        catch (PageException e) {}
      }
      if(format==FORMAT_PNG)    ChartUtilities.writeBufferedImageAsPNG(os, bi);
      else if(format==FORMAT_JPGChartUtilities.writeBufferedImageAsJPEG(os, bi);
      else if(format==FORMAT_GIF)  {
        img = new railo.runtime.img.Image(bi);
        img.writeOut(os, "gif",1,true);
       
        //throw new ApplicationException("format gif not supported");
      }
      else if(format==FORMAT_FLASH)throw new ApplicationException("format flash not supported");
    }
View Full Code Here

  }
 
  @Override
  public void writeOut(PageContext pc,Object source, OutputStream os) throws ConverterException, IOException {
    try {
      Image img = Image.createImage(pc, source, false, true,true,format);
      img.writeOut(os, format, 1, false);
    }
    catch (IOException ioe) {
      throw ioe;
    }
    catch (Exception e) {
View Full Code Here

        }
        else if(o instanceof Image) {
          return ((Image)o).getImageBytes(null);
        }
        else if(o instanceof BufferedImage) {
          return new Image(((BufferedImage)o)).getImageBytes("png");
        }
        else if(o instanceof ByteArrayOutputStream) {
          return ((ByteArrayOutputStream)o).toByteArray();
        }
        else if(o instanceof Blob) {
View Full Code Here

                null, // null for the ImageObserver
                !transparent, // fill background with white
                true  // block until drawing is done
                ));
       
        return new Image(bi);
  }
View Full Code Here

      width=  (int)((width)*s);
      height=  (int)((height)*s);
     
     
    }
    Image img=toImage(page, width, height,transparent);
    img.writeOut(destination,format, overwrite, 1f);
  }
View Full Code Here

      boolean overwrite, boolean goodQuality, boolean transparent) throws PageException, IOException {
    if(scale<1 || scale>100)
      throw new ExpressionException("invalid scale definition ["+Caster.toString(scale)+"], value should be in range from 1 to 100");
   
   
    Image img=null;
    try {
      img = new Image(transparent?dec.getPageAsTransparentImage(page):dec.getPageAsImage(page));
    } catch (PdfException e) {
      throw Caster.toPageException(e);
    }
    if(scale!=100)
      img.resize(scale, goodQuality?"highestquality":"highperformance", 1);
    img.writeOut(destination,format, overwrite, 1f);
  }
View Full Code Here

  }


  public Image toImage(byte[] input,int page) throws IOException, PageException {
     try {
      return new Image(createPdfDecoder(input).getPageAsImage(page));
    } catch (PdfException e) {
      throw Caster.toPageException(e);
    }
  }
View Full Code Here

 
  public Image toImage(byte[] input, int pageNumber, int scale, boolean transparent) throws PageException {
    Document document = toDocument(input);
        BufferedImage bi=toBufferedImage(document,pageNumber,scale/100f,transparent);
    document.dispose();
    return new Image(bi);
  }
View Full Code Here

 
  private static void writeImage(Document document, int page, Resource destination,String format, int scale,
      boolean overwrite, boolean goodQuality, boolean transparent) throws PageException, IOException {
   
    BufferedImage bi=toBufferedImage(document,page,scale/100f,transparent);
    Image img = new Image(bi);
    img.writeOut(destination,format, overwrite, goodQuality?1f:0.5f);
  }
View Full Code Here

TOP

Related Classes of railo.runtime.img.Image

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.