http://bbs.obaoz.com/thread-1440-1-1.html if(rawScreen != null){
//BufferedImage 是什么对象,如何声明
                   BufferedImage image = null;
//landscape 如何声明,什么作用?
                   int width2 = landscape ? rawScreen.height : rawScreen.width;
                   int height2 = landscape ? rawScreen.width : rawScreen.height;
                   if (image == null) {
//BufferedImage?
                       image = new BufferedImage(width2,height2,
                              BufferedImage.TYPE_INT_RGB);
                   } else {
                       if (image.getHeight() != height2 || image.getWidth() != width2) { 
                          image = new BufferedImage(width2, height2,
                                   BufferedImage.TYPE_INT_RGB);
                       }
                   }
                                      int index = 0;
//右移的含义?
                   int indexInc = rawScreen.bpp >> 3;
                   for (int y = 0; y < rawScreen.height; y++) {
                       for (int x = 0; x < rawScreen.width; x++, index += indexInc) {
                           int value = rawScreen.getARGB(index);
                           if (landscape) 
                              image.setRGB(y, rawScreen.width - x - 1, value);
                           else
                              image.setRGB(x, y, value);
                       }
                   }
//ImageIO & RenderedImage 是什么对象,如何声明?
                      ImageIO.write((RenderedImage)image,"PNG",new File("D:/temp.jpg"));
               } 

解决方案 »

  1.   

    LZ可以不必用这种方式,而且人家帖子里也说了//这样我们就可以获得一个设备的类,IDevice,其中有一个getScreenshot()方法获得屏幕截图,类型为RawImage
    //RawImage rawScreen = device.getScreenshot();   后面的方法就和Android无关了,纯粹的转换,Rawimage转换到bufferedimage,再保存 
    RawImage rawScreen = device.getScreenshot();
    有了rawScreen 就够了
      

  2.   

    实在不行就看完整的源码吧,至少保证能用
    http://www.netmite.com/android/mydroid/development/tools/screenshot/src/com/android/screenshot/Screenshot.java
      

  3.   

    我是开发pc套件的,先从socket层发adb,然后返回,对了忘给你说了从android2.0开始截图的图像编码和以往略有不同,嘿嘿
      

  4.   


    [DllImport("coredll.dll", SetLastError=true)]
    internal static extern IntPtr GetDesktopWindow();[DllImport("coredll.dll", SetLastError=true)]
    internal static extern IntPtr GetWindowDC(IntPtr hWnd);
      
    [DllImport("coredll.dll", SetLastError=true)]
    internal static extern bool BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, CopyPixelOperation dwRop); 
    [DllImport("coredll.dll", SetLastError=true)]
    internal static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDC);
      
        IntPtr desktopWindow = GetDesktopWindow();
        if (desktopWindow == IntPtr.Zero)
        {
            throw new Win32Exception();
        }
        IntPtr windowDC = GetWindowDC(desktopWindow);
        if (windowDC == IntPtr.Zero)
        {
            throw new Win32Exception();
        }
        if (!BitBlt(this.hDC, destinationX, destinationY, blockRegionSize.Width, blockRegionSize.Height, windowDC, sourceX, sourceY, copyPixelOperation))
        {
            throw new Win32Exception();
        }
        ReleaseDC(desktopWindow, windowDC);
      

  5.   

    顶!
    求详细代码?
    调用waitDeviceList时,走到 System.err.print("Time out error!");找不到设备。
      private RawImage capture()
      {
        // TODO Auto-generated method stub
        IDevice device;
        AndroidDebugBridge bridge = AndroidDebugBridge.createBridge();
        waitDeviceList(bridge);
        IDevice devices[] = bridge.getDevices();。。 private void waitDeviceList(AndroidDebugBridge bridge)
      {
        // TODO Auto-generated method stub
        int count = 0;
        while (bridge.hasInitialDeviceList() == false)
        {
          try
          {
            Thread.sleep(100);
            count++;
          } catch (InterruptedException e)
          {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
          if (count > 300)
          {
            System.err.print("Time out error!");
          }
        }
      }
      

  6.   

    之前也找过相关方法,好像都不可用都说android截图需要获得root权限,然后就说的乱七八糟的了。。
    现在android2.0后系统自身支持改功能了,不过还没有探索怎么使用系统的改功能。lz从http://bbs.obaoz.com/thread-1440-1-1.html上看到的,是java SDK source中对图片处理的部分代码。对于android平台,可能会不起作用。
    3#楼的就是android2.0发布的ScreenShot的source,建议采用这种方法。探索一下怎么使用,应该是行得通的。
      

  7.   

    好像也可以通过framebuffer来截图....
    帮你顶...
      

  8.   

    弱弱的问下,Android端的程序该怎么写,Android和PC端程序怎么关联,我是菜鸟。刚开始学习Android,谢谢~
      

  9.   


    但要保存这个图片,怎么保存RawImage类型的,而且还要显示出来呢,不显示这种类型的呀