2013-01-23 56 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>