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)) ?
So it was simple to resolve this problem.
Solution:
I have an object(orange square) with OnTouchListener(for e.g. he's an quad with size 50dp Height/ 50dp Width).
So view.getX()/view.getY() takes relative coords(center) of object(that have OnTouchListener).
So what i needed:
//imageview parameters ,where i will show this part of bitmap
int Width = img.getWidth();
int Height = img.getHeight();
//after this,i make margin of my coords,via this simple formula -> Current Coord X - Width / 2 (same for Y)
Bitmap mBitmap = Bitmap.createBitmap(sourceBitmap,view.getX() - Width / 2,view.getY()-Height / 2,Width,Height);
And that is all.
Enjoy!