I have this :
and what i want exactly is that to show portion of Bitmap via coords(X,Y) of object with OnTouchListener(orange square with dot in center).
So the problem is that i want to draw portion of image like it shows on image(Red square "Area that i want" to show).
So in this case,excepted result is(portion of bitmap) :
At current moment i'm doing like this:
public boolean onTouch(View view, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_MOVE:
Bitmap mBitmap = Bitmap.createBitmap(sourceBitmap,view.getX() - view.getWidth(),view.getY()-view.getHeight(),250,250);
//other stuff to fill this portion of bitmap
break;
}
return true;
}
}
And it's not correct.
how can i achieve this?
Tried a lot of formulas,but no luck. Any suggestions?
PS As i understand event.getX()/event.getY() is getting relative coords(and it's not clear for me,what exactly coords getting from object of imageview with touch listener(orange square with dot in center),i mean its getting center of this objects or Top.Left corners(X,Y)) ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…