截屏代码
来源:互联网 发布:淘宝店下架宝贝怎么做 编辑:程序博客网 时间:2024/04/28 15:16
截取应用
private void getScreen(){ View content = findViewById(R.id.layoutroot); Bitmap bitmap = content.getDrawingCache(); File file = new File( Environment.getExternalStorageDirectory() + "/test.png"); try { file.createNewFile(); FileOutputStream ostream = new FileOutputStream(file); bitmap.compress(CompressFormat.PNG, 100, ostream); ostream.close(); } catch (Exception e) { e.printStackTrace(); }}
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
view 写入图片
public Bitmap screenShot(View view) { Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); view.draw(canvas); return bitmap;}
Bitmap bitmap = Bitmap.createBitmap(width, height,Config.ARGB_8888);//创建一个你需要尺寸的BitmapCanvas canvas = new Canvas(bitmap);//用这个Bitmap生成一个Canvas,然后canvas就会把内容绘制到上面这个bitmap中Paint paint = new Paint();//定义一个画笔paint.setColor(Color.RED);//红色画笔canvas.drawText(text, x, y , paint);//绘制文案//绘制LogoBitmap logo = xxx;//获得你的Logobitmapcanvas.drawBitmap(logo, x,y, logo.getWidth(), logo.getHeight());
0 0
- 截屏的代码
- java截屏代码
- C++截屏代码
- symbian 截屏代码
- Android代码截屏
- android截屏代码
- 截屏代码
- Android代码截屏
- Andorid截屏代码
- 截屏代码
- C#截屏代码
- Java截屏代码
- iOS 截屏代码
- Android代码截屏
- .net截屏代码
- android截屏代码
- c# 截屏代码
- 截屏代码 地图
- OC语法--strong和weak指针
- android升级–升级包的制作
- Scala简史 对象函数式编程
- 面向连接服务、无连接服务
- Hibernate如何提升数据库查询的性能
- 截屏代码
- SSH人力资源管理系统
- IOT平台之Alljoyn(allseen物联网联盟--from-qualcom)
- 对套接字的深入理解
- lrs_receive函数超时问题
- SQL剔除节假日function
- Hibernate总结
- java中File操作——getPath和getAbsolutePath和getCanonicalPath
- 黑马程序员--网络编程