webview 화면을 캡쳐해서
이미지로 저장하려고 하는데요.
스크롤이된 영역까지(화면에 안보이는부분) 캡쳐를 하려면 어떻게
구현을 해야할까요?^^;
view.setDrawingCacheEnabled(true);
Bitmap screenshot = view.getDrawingCache();
String filename = "screenshot.png";
try {
File f = new File(Environment.getExternalStorageDirectory(), filename);
f.createNewFile();
OutputStream outStream = new FileOutputStream(f);
screenshot.compress(Bitmap.CompressFormat.PNG, 100, outStream);
outStream.close();
} catch (IOException e) {
e.printStackTrace();
}
view.setDrawingCacheEnabled(false);
와 같이 구현했더니 스크롤되는영역(화면이 안보이는 부분)은 캡쳐가 되지 않더라구요@.@
추가로 다음과 같이 구현하면 그냥 회색배경의 이미지가 나오네요;;
Picture picture = mWebView.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( "/sdcard/myimage.png" );
if (fos != null) {
b.compress(Bitmap.CompressFormat.JPEG, 90, fos );
fos.close();
}
} catch( Exception e ){}