-1
我正在工作的应用程序,其中我需要html页面的缩略图,以便将这些图像放在图库中滚动并在View pager中显示该图像。如何获取HTML页面的缩略图在android
我正在工作的应用程序,其中我需要html页面的缩略图,以便将这些图像放在图库中滚动并在View pager中显示该图像。如何获取HTML页面的缩略图在android
Bitmap getPreview(URI uri) {
File image = new File(uri);
BitmapFactory.Options bounds = new BitmapFactory.Options();
bounds.inJustDecodeBounds = true;
BitmapFactory.decodeFile(image.getPath(), bounds);
if ((bounds.outWidth == -1) || (bounds.outHeight == -1))
return null;
int originalSize = (bounds.outHeight > bounds.outWidth) ? bounds.outHeight
: bounds.outWidth;
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inSampleSize = originalSize/THUMBNAIL_SIZE;
return BitmapFactory.decodeFile(image.getPath(), opts);
}
使用WebView看看View.getDrawingCache(),WebView.capturePicture()和View.draw()。不要忘记在绘制之前测量和布置WebView。如果您使用第一种方法,也会在捕获后禁用绘图缓存。
感谢您的回复@praetorian droid,但我想要所有的html页面缩略图。只给出当前视图缩略图的这些方法 –
将您的页面加载到WebView中,您将获得页面的缩略图。为所有页面执行此操作并使用位图:根据需要滚动或连接它们。 –