撕开美女的衣服

来源:互联网 发布:手机淘宝如何收藏宝贝 编辑:程序博客网 时间:2024/04/16 20:53
public class MainActivity extends Activity {private ImageView iv_back;private ImageView iv_up;private Bitmap alterBitmap;private Canvas canvas;private Paint paint;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);iv_back = (ImageView)findViewById(R.id.iv_back);iv_up = (ImageView)findViewById(R.id.iv_up);BitmapFactory.Options opts = new Options();//opts.inSampleSize = 2;Bitmap back = BitmapFactory.decodeResource(getResources(), R.drawable.g16_back, opts);//只读图片Bitmap up = BitmapFactory.decodeResource(getResources(), R.drawable.g16_up, opts);//可以修改的空白bitmap,mutablealterBitmap = Bitmap.createBitmap(up.getWidth(), up.getHeight(), up.getConfig());canvas = new Canvas(alterBitmap);paint = new Paint();paint.setStrokeWidth(5);paint.setColor(Color.BLACK);canvas.drawBitmap(up, new Matrix(), paint);iv_back.setImageBitmap(back);iv_up.setImageBitmap(alterBitmap);iv_up.setOnTouchListener(new OnTouchListener() {@Overridepublic boolean onTouch(View v, MotionEvent event) {switch(event.getAction()){case MotionEvent.ACTION_DOWN:break;case MotionEvent.ACTION_MOVE:int newX = (int) event.getX();int newY = (int) event.getY();int xx, yy;for(int i=-8; i<=8; i++){for(int j=-8; j<=8; j++){alterBitmap.setPixel(xx, yy, Color.TRANSPARENT);}}iv_up.setImageBitmap(alterBitmap);break;}return true;}});}}


<FrameLayout 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:id="@+id/iv_back"        android:layout_width="wrap_content"        android:layout_height="wrap_content"         />    <ImageView        android:id="@+id/iv_up"        android:layout_width="wrap_content"        android:layout_height="wrap_content"         /></FrameLayout>