这是用于显示wibview然后采用webview截图的代码。图像存储到SD卡中。现在我想转换它而不存储。我想问的意思是我想将屏幕截图转换为PDF格式然后我想通过连接WiFi来打印输出。请帮帮我。
import java.io.FileOutputStream;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Picture;
import android.os.Bundle;
import android.view.Menu;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class MainActivity extends Activity {
WebView w ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
w = new WebView(this);
w.setWebViewClient(new WebViewClient()
{
public void onPageFinished(WebView view, String url)
{
Picture picture = view.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/yahoo.jpg" );
if ( fos != null )
{
b.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.close();
}
}
catch( Exception e )
{
}
}
});
setContentView(w);
w.loadUrl("http://google.com");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}