title: Absolute coordinates bitmap android
body: <p>I have a bitmap with a size greater than screen (i.e, 1000x1000). I can drag this bitmap thanks to canvas. If i am in the point (500,500) getX or getY don´t return 500 else some value between 0 and 320[screen size emulator], so I need to know the absolute value with respect to point 0. I want my View not to translate the bitmap more than the 0 Left and 0 Top points of the View</p>
  
  <p>I put some code to clarify the question</p>
  
  <pre><code>public MapaView(Context context, AttributeSet attrs) {
      super(context, attrs);
  
      mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
      mSurfaceHeight = 640;
      mSurfaceWidth = 480;
      mapaActual = new Mapa();
      mContext = context;
      mBufferedCanvas = new Canvas();
  
  }
  
  
      draw(Canvas c){ 
  
      bitmapAux.eraseColor(Color.WHITE);
  
     /*draw the rectangles....*/
  
      c.translate(mPosX, mPosY);
      c.scale(mScaleFactor, mScaleFactor);
      c.drawBitmap(bitmapAux, 0, 0, null);}
  </code></pre>
  
  <p>I get the position with next method</p>
  
  <pre><code>@Override
      public boolean onTouchEvent(MotionEvent ev) {
          // Let the ScaleGestureDetector inspect all events.
          mScaleDetector.onTouchEvent(ev);
  
  
          final int action = ev.getAction();
          switch (action &amp; MotionEvent.ACTION_MASK) {
          case MotionEvent.ACTION_DOWN: {
              startTime = ev.getEventTime();
              final float x = ev.getX();
              final float y = ev.getY();
              final float xR= ev.getRawX();
              final float yR= ev.getRawY();
              movido=false;
              mLastTouchX = x;
              mLastTouchY = y;
              mLastTouchXRaw = xR;
              mLastTouchYRaw = yR;
  
              mActivePointerId = ev.getPointerId(0);
  
              break;
          }
  
          case MotionEvent.ACTION_MOVE: {
              final int pointerIndex = ev.findPointerIndex(mActivePointerId);
              final float x = ev.getX(pointerIndex);
              final float y = ev.getY(pointerIndex);
  
              // Only move if the ScaleGestureDetector isn't processing a gesture.
              if (!mScaleDetector.isInProgress()) {
                  final float dx = x - mLastTouchX;
                  final float dy = y - mLastTouchY;
  
                  mPosX += dx;
                  mPosY += dy;
  
                  movido=true;
                  invalidate();
              }
  
              mLastTouchX = x;
              mLastTouchY = y;
              movido=true;
  
  
              break;
          }
  
          case MotionEvent.ACTION_UP: {
              mActivePointerId = INVALID_POINTER_ID;
              endTime = ev.getEventTime();
  
              if ((endTime - startTime &gt; 500)&amp;&amp;!movido) {
  
                  // we have a 1000ms duration touch
                  // propagate your own event
                  Log.d("LC", "time touched greater than 1000ms " + endTime + "  "
                          + startTime);
  
                  startTime = 0;
                  endTime = 0;
                  movido=false;
                  Box pepeBox=new Box();
                  pepeBox=buscarElemento();
                  //Intent intent=new Intent(mContext,OpcionesConceptoList.class);
                  //mContext.startActivity(intent);
                  /*
                   * return true; notify that you handled this event (do not
                   * propagate)
                   */
              }
              break;
          }
  
          case MotionEvent.ACTION_CANCEL: {
              mActivePointerId = INVALID_POINTER_ID;
              break;
          }
  
          case MotionEvent.ACTION_POINTER_UP: {
              final int pointerIndex = (ev.getAction() &amp; MotionEvent.ACTION_POINTER_INDEX_MASK) &gt;&gt; MotionEvent.ACTION_POINTER_INDEX_SHIFT;
              final int pointerId = ev.getPointerId(pointerIndex);
              if (pointerId == mActivePointerId) {
                  // This was our active pointer going up. Choose a new
                  // active pointer and adjust accordingly.
                  final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
                  mLastTouchX = ev.getX(newPointerIndex);
                  mLastTouchY = ev.getY(newPointerIndex);
                  mActivePointerId = ev.getPointerId(newPointerIndex);
              }
              break;
          }
  
          }
  
  
  
          return true;
      }
  </code></pre>
  
  <p>Any advice?</p>
  
  <p>Thanks in advance and excuse my english.</p>