Android Bitmap之擦掉图片(扒衣服)
来源:互联网 发布:人证比对软件 编辑:程序博客网 时间:2024/05/17 06:27
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:src="@drawable/after" /> <ImageView android:id="@+id/iv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" /></RelativeLayout>
public class MainActivity extends Activity { private ImageView iv; // 可以修改的位图 private Bitmap alertBitmap; private Canvas canvas; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); iv = (ImageView) findViewById(R.id.iv); Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.pre); // 创建一个空白的原图的拷贝 alertBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), bitmap.getConfig()); canvas = new Canvas(alertBitmap); Paint paint = new Paint(); paint.setColor(Color.BLACK); canvas.drawBitmap(bitmap, new Matrix(), paint); iv.setImageBitmap(alertBitmap); iv.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN:// 手指按下屏幕 System.out.println("action down"); break; case MotionEvent.ACTION_MOVE:// 手指在屏幕上移动 int x = (int) event.getX();// getX,相对于控件,getRawX,相对于屏幕 int y = (int) event.getY(); System.out.println("设置(" + x + "," + y + ")透明颜色"); for (int i = -4; i < 5; i++) { for (int j = -4; j < 5; j++) { try { alertBitmap.setPixel(x + i, y + j, Color.TRANSPARENT); } catch (Exception e) { // TODO: handle exception } } } iv.setImageBitmap(alertBitmap); break; case MotionEvent.ACTION_UP:// 手指离开屏幕 MediaPlayer.create(getApplicationContext(), R.raw.higirl) .start(); break; } return true;// 代表事件被消费, 可以重复循环的处理事件 } }); }}
参考:
Android图片处理
0 0
- Android Bitmap之擦掉图片(扒衣服)
- Android:简单实现美女扒衣服小游戏
- 图片加载到内存、原图实现画画、扒衣服
- android(40)(撕衣服,bitmap的使用)
- Android优化之bitmap图片
- Android图片之bitmap缩略图
- Android图片之Bitmap、BitmapFactory
- android之bitmap处理图片
- Android之Canvas撕衣服
- Android图片缓存之Bitmap详解(一)
- android之图片(bitmap)总结 持续学习中......
- Android图片缓存之Bitmap详解(一)
- Android 图片操作(Bitmap)
- Android 图片操作(Bitmap)
- Android 图片操作(Bitmap)
- Android图片操作(Bitmap)
- Android编程之Bitmap图片压缩大小
- Android编程之Bitmap图片压缩大小
- JDBC
- 确定比赛名次(拓扑排序)
- 剑指offer-34.第一个只出现一次的字符
- [BZOJ2338][HNOI2011]数矩形(计算几何)
- STL初入
- Android Bitmap之擦掉图片(扒衣服)
- SQL Server如何启用xp_cmdshell组件
- cmake的使用
- 护照阅读机出入境运用SDK
- mysql入门知识
- 用会声会影剪辑视频快速入门技巧
- [李景山php]centos7 安装php 多线程
- POJ 2718 Smallest Difference(贪心 or next_permutation暴力枚举)
- tf 原理二