2013-01-23 57 views
0

如何获取网页截图的截图,如果它太长,并将其存储在内部存储。因此,例如,如果我的webview显示“google.com”,并且我尝试下面的代码,它会截取屏幕截图并将其存储为.jpg。但如果我的webview显示“stackoverflow.com”,由于这个网页太长,应用程序崩溃。一些帮助将不胜感激。长网页的Android截图

Picture picture=this.getCurrentWebView().capturePicture(); 
    Bitmap b = Bitmap.createBitmap(picture.getWidth(), picture.getHeight(), Bitmap.Config.ARGB_8888); 
    Canvas c = new Canvas(b); 
    picture.draw(c); 
      FileOutputStream fos = null; 
      try { 
       fos = new FileOutputStream("mnt/sdcard/myjpg.jpg"); 
        if (fos != null){ 
         b.compress(Bitmap.CompressFormat.JPEG, 100, fos); 
         fos.close(); 
        } 
       } 
      catch(Exception e) 
      { 
      } 
+0

我希望从一个长的WebView创建多个图像,并将其存储在一个文件夹或文件。 – user1932345

回答

0

不知道,如果你想通了,但是这可能帮助:

添加机器人:largeHeap = “true” 以你的Mainfest。

喜欢的东西...

<application 
     android:allowBackup="true" 
     android:label="@string/app_name" 
     android:icon="@drawable/ic_launcher" 
     android:theme="@style/AppThemeHolo" 
     android:largeHeap="true" 
     > 
... 

... 
</application>