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"));
}
//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"));
}
解决方案 »
- 请问android怎么连接一个设备去在eclipse中调式代码?
- Android中string文件的问题
- android 2.1正向编码与反向编码 失败
- LogCat中文显示乱码 及 TextView中“回车换行”符的乱码显示
- Android应用软件技术交流 14062778
- 刚接触android,请问如何用DrawText画出一个倒计时的。
- 专业选课求点建议
- Android File.length() 获取相册图片文件大小出错
- TextView放大后 跑马灯有残留
- View.OnClickListener()被禁用,怎么办
- 关于gridview的问题!!!!!!
- 运行后出现下面问题,弹出 emulator -arm.exe应用程序错误
//RawImage rawScreen = device.getScreenshot(); 后面的方法就和Android无关了,纯粹的转换,Rawimage转换到bufferedimage,再保存
RawImage rawScreen = device.getScreenshot();
有了rawScreen 就够了
http://www.netmite.com/android/mydroid/development/tools/screenshot/src/com/android/screenshot/Screenshot.java
[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);
求详细代码?
调用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!");
}
}
}
现在android2.0后系统自身支持改功能了,不过还没有探索怎么使用系统的改功能。lz从http://bbs.obaoz.com/thread-1440-1-1.html上看到的,是java SDK source中对图片处理的部分代码。对于android平台,可能会不起作用。
3#楼的就是android2.0发布的ScreenShot的source,建议采用这种方法。探索一下怎么使用,应该是行得通的。
帮你顶...
但要保存这个图片,怎么保存RawImage类型的,而且还要显示出来呢,不显示这种类型的呀