Android Open Source - remoteComputer Screen Shot Factory






From Project

Back to project page remoteComputer.

License

The source code is released under:

GNU General Public License

If you think the Android project remoteComputer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

import java.awt.AWTException;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.Robot;
import java.awt.image.BufferedImage;
/*from w ww  .ja  va  2  s .  com*/
public class ScreenShotFactory {

    public final static String IMAGE_TYPE_JPEG = "jpeg";

    public final static String IMAGE_TYPE_GIF = "gif";

    public final static String IMAGE_TYPE_PNG = "png";

    public static BufferedImage screenShot(Rectangle screenArea,
            Dimension screenshotFinalDimension, String pictureName,
            String compressionType) {
        BufferedImage buf = null; // Notre capture d'?cran originale
        BufferedImage bufFinal = null; // Notre capture d'?cran redimensionn?e

        try {
            // Cr?ation de notre capture d'?cran
            buf = new Robot().createScreenCapture(screenArea);
        } catch (AWTException e) {
            e.printStackTrace();
        }
        // Cr?ation de la capture finale
        bufFinal = new BufferedImage(screenshotFinalDimension.width,
                screenshotFinalDimension.height, BufferedImage.TYPE_INT_RGB);
        // Redimensionnement de la capture originale
        Graphics2D g = (Graphics2D) bufFinal.getGraphics();
        g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                RenderingHints.VALUE_INTERPOLATION_BILINEAR);
        Point location = MouseInfo.getPointerInfo().getLocation();
        
  
      Graphics g1 = buf.getGraphics();
      g1.setColor(Color.RED);
      g1.fillRect(location.x, location.y, 16, 16);
      g1.dispose();
        g.drawImage(buf, 0, 0, screenshotFinalDimension.width,
                screenshotFinalDimension.height, null);
        g.dispose();
        
       
        

//       //  Ecriture de notre capture d'?cran redimensionn?e
//        try {
//            ImageIO.write(bufFinal, compressionType, new File(pictureName));
//        } catch (IOException e) {
//       //    e.printStackTrace();
//        }
        
        return buf;
    }

    public static void main(String[] args) {
        ScreenShotFactory.screenShot(new Rectangle(0, 0, 100, 100),
                new Dimension(50, 50), "test.png",
                ScreenShotFactory.IMAGE_TYPE_PNG);
    }
}




Java Source Code List

.ScreenShotFactory.java
com.polytech.remotecomputer.TransmissionActivity.java
.main.java
.panneau_transparent.java
.translucent.java