package org.wc.bitmap;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.MotionEvent;
import android.widget.AbsoluteLayout.LayoutParams;
import android.widget.ImageView;
public class adadextends Activity {
private Bitmap bitmap;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bitmap = BitmapFactory
.decodeResource(getResources(), R.drawable.matrix);
ImageView imageView = (ImageView) findViewById(R.id.imageView);
imageView.setImageBitmap(bitmap);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
ImageView iv = (ImageView) findViewById(R.id.iv);
int postionX = (int) event.getX();
int postionY = (int) event.getY();
LayoutParams lp = new LayoutParams(300, 300, postionX - 150,
postionY - 150);
iv.setLayoutParams(lp);
postionX = (int) event.getX() - 50;
postionY = (int) event.getY() - 50;
if (postionX < 0) {
postionX = 0;
}
if (postionY < 0) {
postionY = 0;
}
Bitmap bm = Bitmap.createBitmap(bitmap, postionX, postionY, 100, 100);
iv.setImageBitmap(bm);
return super.onTouchEvent(event);
}
}