Package com.liusoft.dlog4j.photo

Examples of com.liusoft.dlog4j.photo.PhotoSaver


   * @param orient
   * @return
   * @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;
        double xRot = 0;
        double yRot = 0;
    switch(orient){
    case 3:
      radian = 180.0;
      xRot = width/2.0;
      yRot = height/2.0;
    case 6:
      radian = 90.0;
          xRot = height/2.0;
          yRot = xRot;
      break;
    case 8:
      radian = 270.0;
          xRot = width/2.0;
          yRot = xRot;
          break;
        default:
          return false;
    }
        newXform.rotate(Math.toRadians(radian), xRot, yRot);

        g2d.setTransform(newXform);  
        // draw image centered in panel
        g2d.drawImage(old_img, 0, 0, null);
        // Reset to Original
        g2d.setTransform(origXform);
        OutputStream out = saver.write(ctx, imgURL);
        try{
          ImageIO.write(new_img, "JPG", out);
        }finally{
          out.close();
        }
View Full Code Here

TOP

Related Classes of com.liusoft.dlog4j.photo.PhotoSaver

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.