
Untitled
By: a guest on
May 15th, 2012 | syntax:
None | size: 1.79 KB | hits: 16 | expires: Never
Saving overlapped image on SD card
mybitmap = BitmapFactory.decodeFile(imgfile.getAbsolutePath());
d = new BitmapDrawable(mybitmap);
windowwidth = getWindowManager().getDefaultDisplay().getWidth();
windowheight = getWindowManager().getDefaultDisplay().getHeight();
female = (ImageView) findViewById(R.id.image);
female.setBackgroundDrawable(d);
goggle = (ImageView) findViewById(R.id.image1);
goggle.setOnTouchListener(this);
public boolean onTouch(View v, MotionEvent event) {
switch (v.getId()) {
case R.id.image1:
ImageView image1 = (ImageView) findViewById(R.id.image1);
layoutParams1 = (LayoutParams) image1.getLayoutParams();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_MOVE:
int x_cord = (int) event.getRawX();
int y_cord = (int) event.getRawY();
if (x_cord > windowwidth) {
x_cord = windowwidth;
}
if (y_cord > windowheight) {
y_cord = windowheight;
}
layoutParams1.leftMargin = x_cord - 70;
layoutParams1.topMargin = y_cord - 280;
image1.setLayoutParams(layoutParams1);
break;
default:
break;
}
}
return true;
}
public static Bitmap getBitmapFromURL(String src) {
try {
URL url = new URL(src);
HttpURLConnection connection = (HttpURLConnection) url
.openConnection();
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
Bitmap mybitmap = BitmapFactory.decodeStream(input);
return mybitmap;
} catch (Exception ex)
{
return null;
}
}
}