все спасибо разобрался)Nik писал(а):а можно еще вопрос по коду?WizikTLT писал(а):Попробуй так - не получится напиши что в лог выводит (при проверке я сохранял не на sdcard, а во внутреннее хранилище - все отлично сохранилось)Код: Выделить всё
private void SavePicture (WebView webView1, String folderToSave) { Picture picture = webView1.capturePicture(); Time time = new Time(); time.setToNow(); Bitmap b = Bitmap.createBitmap( picture.getWidth(),picture.getHeight(), Bitmap.Config.ARGB_8888); Canvas c = new Canvas( b ); picture.draw( c ); FileOutputStream fos = null; try { File root = Environment.getExternalStorageDirectory(); fos = new FileOutputStream(root+"/"+ Integer.toString(time.year) + Integer.toString(time.month) + Integer.toString(time.monthDay) + Integer.toString(time.hour) + Integer.toString(time.minute) + Integer.toString(time.second) +".jpg"); if ( fos != null ) { b.compress(Bitmap.CompressFormat.JPEG, 90, fos ); fos.close(); } } catch( Exception e ) { System.out.println("-----error--"+e); } }
p.s был занят вот и не отвечал =)вот в этом месте .capturePicture(); эклипс зачеркивает? почему? и говорит на сколько понимаю английский что устарела.Код: Выделить всё
Picture picture = webView1.capturePicture();
Сохранить изображение из webView
Re: Сохранить изображение из webView
Re: Сохранить изображение из webView
Да так и есть, он устарел - в описании есть ссылки на другие методы, которые можешь изучить и поменять код.
Проверь во так
Код: Выделить всё
private void SavePicture (WebView webView1, String folderToSave) {
Time time = new Time();
time.setToNow();
Bitmap image = Bitmap.createBitmap(webView1.getWidth(), webView1.getHeight(),Config.ARGB_8888);
Canvas canvas = new Canvas();
webView1.draw(canvas);
canvas.setBitmap(image);
FileOutputStream fos = null;
try
{
File root = Environment.getExternalStorageDirectory();
fos = new FileOutputStream(root+"/"+ Integer.toString(time.year) + Integer.toString(time.month) + Integer.toString(time.monthDay) + Integer.toString(time.hour) + Integer.toString(time.minute) + Integer.toString(time.second) +".jpg");
if ( fos != null )
{
image.compress(Bitmap.CompressFormat.JPEG, 90, fos );
fos.close();
}
}
catch( Exception e )
{
System.out.println("-----error--"+e);
}
}