Home > Default > How to capturing scrolling images with no java controls?

How to capturing scrolling images with no java controls?

November 30Hits:0
Advertisement
Can somebody help me? I am trying to capture the image of the browser, using the followed code to do it, but I can not take it scrolling the screen. I do not use any control of java in the browser. Does anybody have an idea?
Robot r = new Robot();
image1 = r.createScreenCapture(clippedScreen);
File file = new File("c:\\Csa\\3.9\\Fimages\\"+counter+".jpg");
javax.imageio.ImageIO.createImageOutputStream(file);
ImageIO.write(image1,"jpg",file);
//Scroll the screen
scrollTheScreen ();
//Takes scrolled area
image2 = r.createScreenCapture(new Rectangle(0,666,1280,80));
File file2 = new File("c:\\Csa\\3.9\\Fimages\\"+counter+1+".jpg");
javax.imageio.ImageIO.createImageOutputStream(file2);
ImageIO.write(image2,"jpg",file2);
As you can see I take two parts of the screen but I am having troubles adding the images, I do not know if there is an easier way to do this.
Thank you in advance.

Answers

Thanks to anybody, but i found the way on how to capture the image.
1. Take a snapshot of the screen.
2. Scroll the screen pushing the button down.
3. Take the snapshot of the scrolled part of the screen.
4. Scroll the screen pushing the button down.
5. Take the snapshot of the scrolled part of the screen.
6. Compare the 2 last images, if they are equals, stop scrolling, else scroll again.
7. Join the images first, second and third images, to get a single one corresponding to the hole info of the browser.
8. Save the resulting image.
The thing in this problem is to manage the images as RGB components for that you must use the getPixel(col, row, color); method to manipulate the components in matrix and added to a bigger matrix where you join the complete components. Be sure that you manage the 3D matrix correctly, [width of the screen] [height of the screen] [RGB components], i.e.
* This saves just the red component, the green and blue must be saved too.
public int[][] imreadRed(BufferedImage bi)
          Raster r = null;     // * Raster
          int [][] image;     // * Image array
          int imageWidth = bi.getWidth();     // * Image Width
          int imageHeight = bi.getHeight();     // * Image Height
          int[] color = new int[3];     // * array to colors RGB (r -> 0, g -> 1, b -> 2)
          r = bi.getData();
          image = new int[imageHeight][imageWidth];
          for(int row = 0; row < imageHeight; row++)
               for(int col = 0; col < imageWidth; col++)
                    r.getPixel(col, row, color);
                    image[row][col] = color[0];          //Saves the red color to the array image on the first coordinate
          return image;     //Return the array with the red component
     }* This merge the matrix into a bigger one.
public int [][] mergeMatrix (int [][] mat1, int [][] mat2){
         int rowsMat1 = (mat1.length-53), colsMat1 = mat1[0].length,     //mat1.length da los renglones de la matriz height  
         rowsMat2 = mat2.length, colsMat2 = mat2[0].length;          //mat1[0].length da las columnas de la matriz width
         int [][] addedMatrix = new int [rowsMat1+rowsMat2][colsMat1];
         for (int row = 0; row < rowsMat1; row++) {
              for (int col = 0; col < colsMat1; col++) {
                   addedMatrix [row] [col] = mat1 [row] [col];
          for (int row=0; row < rowsMat2; row++) {
               for (int col = 0; col < colsMat2; col++) {
                    addedMatrix [rowsMat1+row] [col]  = mat2 [row] [col];
         return addedMatrix;
    }* This convert the matrix into an image.
public BufferedImage imwriteComponents (int [][] arrRedImg, int [][] arrGreenImg, int [][] arrBlueImg) {
          int arrayWidth = arrRedImg[0].length;     // * Image Width
          int arrayHeight = arrRedImg.length;     // * Image Height
          BufferedImage completeImage = new BufferedImage(arrayWidth, arrayHeight, BufferedImage.TYPE_INT_RGB);     // Create a BufferedImage with RGB pixels
          WritableRaster wRaster = completeImage.getRaster();     // Create a raster so we can access the BufferedImage pixels
          int [] color = new int [3];     //color variable to save all the components
          //join the 3 matrix in one color type
          for(int row = 0; row < arrayHeight; row++)
               for(int col = 0; col < arrayWidth; col++) {
                    color [0] = arrRedImg [row][col];
                    color [1] = arrGreenImg [row][col];
                    color [2] = arrBlueImg [row][col];
                    wRaster.setPixel(col, row, color);
          return completeImage;     //Return the Buffered image with the red array component
    }That is a solution that I found to this problem, if someone has an easy way to do it please tell us.
Thank you.

Read other 2 answers

Tags:

Related Articles

  • How to capturing scrolling images with no java controls?November 30

    Can somebody help me? I am trying to capture the image of the browser, using the followed code to do it, but I can not take it scrolling the screen. I do not use any control of java in the browser. Does anybody have an idea? Robot r = new Robot(); im

  • Capturing audio through applet using Java SoundNovember 30

    hi fellows i need ur help. I am working on a voice project to Capture & Play the sound using java sound API instead of JMF. I can capture , play and transmit the sound through application. It works pretty fine but when i convert it to the applet, it

  • NO java control panel in windows system control windowOctober 11

    Hello together, there seems to be a bug/feature (?) not allowing me to use the plugin functionality of my J2EEsdk-1_4 Situation: Before i installed the J2EE i had an already installed java plug-in 1_4_2 working fine on my Laptop giving my ms explorer

  • Java Control Panel wont open at all and any Java Applets crash web browsersOctober 11

    Hello, I recently installed a fresh fully updated copy of Windows 7 Home Premium 64 bit, and I have not for the life of me been able to get Java working at all. Java version is the latest JRE 6U31. I only have Internet Explorer 9 installed but I doub

  • Java Control Panel quit unexpectedly while using the libjvm.dylib plug-in.October 11

    OS X Server1 0.8.4, Mac Mini (5,1), Java 7u25 (jre-7u25-macosx-x64.dmg). Tried removing and re-installing Java 7u25 directly from Oracle's site.  Also did a fix disk permissions, rebuilt caches, deleted java caches,  etc...  I can't simply get the Ja

  • How do I reuse a custom java control in another project?October 11

    Relatively simple question, but I am having a lot of trouble with this. Documentation alludes to this being possible and easy, but never says how (and the only tutorials I can find describe creating a custom java control in the same project where the

  • How to change a setting in the Java Control Panel with command lineOctober 11

    Hi, I am trying to figure out how to change a setting in the Java Control Panel with command line or with a script. I want to enable "Use SSL 2.0 compatible ClientHello format" I can't seem to find any documentation on how to change settings in

  • JRE 6 freeze browsers and Java Control Panel Applet stops working!October 11

    Hello, this is the second time I got this problem with Java JRE 6 ! First one was a month or two ago: I have Java JRE 6 update 20 installed on a Windows 7 64bit ultimate. It was working...much time ago...then i found my browser (firefox, google chrom

  • Can't shut down after opening Java Control PanelOctober 11

    Hello, I'm just a regular guy with Windows ME and since I installed JRE 1.4.2_02 (for Mozilla 1.5), I can't shut down my pc after opening the Java Control Panel. Javaw.exe stays in memory (Norton System Information) even after the JCP has been closed

  • Problem increasing heap size using Java Control PanelOctober 11

    I am running a web-based bioinformatics package which uses a Java applet as the client application. It mostly works fine, but some large clustering processes don't complete, they just cycle endlessly. The user manual advises increasing heap space "by

Copyright (C) 2019 wisumpire.com, All Rights Reserved. webmaster#wisumpire.com 14 q. 0.607 s.