Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8527431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:33:20+00:00 2026-06-11T08:33:20+00:00

‘m developing an application in which I’m pasting images, doing drawing and painting on

  • 0

‘m developing an application in which I’m pasting images, doing drawing and painting on canvas. This app can also Scale up/down the canvas or drag it to different location. My problem is: I can’t get the correct canvas coordinates after scaling or dragging the canvas. I want to draw finger paint after the canvas is scaled or dragged but unable to retrieve the right place where i’ve touched…

@Override
public boolean onTouchEvent(MotionEvent event) {

    scaleListener.onTouchEvent(event);

    synchronized(thread.getSurfaceHolder()){

        switch ( event.getAction() & MotionEvent.ACTION_MASK ){

            case MotionEvent.ACTION_DOWN :
                // Remember our initial down event location.
                savedMatrix.set(m_matrix);
                start.set(event.getX() , event.getY());
                mode = DRAG;                
            break;

            case MotionEvent.ACTION_POINTER_DOWN :

                oldDist = spacing(event);
                if (oldDist > 10f) {

                    savedMatrix.set(m_matrix);
                    m_matrix.getValues(matrixValues);
                    midPoint(mid, event);
                    mode = ZOOM;
                }

             break;

            case MotionEvent.ACTION_UP :
            case MotionEvent.ACTION_POINTER_UP :
                    mode = NONE;

            break;

            case MotionEvent.ACTION_MOVE :

                if(mode==DRAG && isDragAllowd){
                        m_matrix.set(savedMatrix);
                        rebound(event.getX() , event.getY());
                }
                else if(mode==ZOOM){

                    float newDist = spacing(event);
                    if (newDist > 10f){

                            m_matrix.set(savedMatrix);

                            float scale = newDist/oldDist;
                            m_matrix.getValues(matrixValues);
                            float currentScale = matrixValues[Matrix.MSCALE_X];

                            // limit zoom
                            if (scale * currentScale > maxZoom){
                                    scale = maxZoom / currentScale;
                                    //scale = maxZoom;
                            }
                            else if (scale * currentScale < minZoom){
                                    scale = minZoom / currentScale;
                                    //scale = minZoom;
                            }

                            m_matrix.postScale(scale, scale, mid.x, mid.y);
                            m_matrix.getValues(matrixValues);

                  }

            }
       break;

    }

    return true; //done with this event so consume it


    }       

}

@Override
protected void onDraw(Canvas canvas){
    super.onDraw(canvas);

            canvas.drawColor(Color.WHITE);
        canvas.drawBitmap(currentBitmap, m_matrix, null);
        c2.drawColor(Color.BLACK); 
        commandManager.executeAll(c2); // Drawing all the Paints on Canvas c2
        // Overlay bitmap it's a transparent layour 
            canvas.drawBitmap(overlayBitmap, 0, 0, pTouch);

}

when user zoom the bitmap he is not able to draw over it , after zooming drawing doesn’t happen at proper place.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:33:21+00:00Added an answer on June 11, 2026 at 8:33 am

    use the following equation for transformed the points, after that user will not face an any difficulty painting during zoom or after scrolling.

     float f1 = (( motionEvent.getX() - m_transformedPoints[0] )/( m_transformedPoints[2] - m_transformedPoints[0] ))*currentBitmapWidth;
         float f2 = (( motionEvent.getY() - m_transformedPoints[1] )/( m_transformedPoints[3] - m_transformedPoints[1] ))*currentBitmapHeight; 
    
        //calculate the transformed view in onDraw Method
        this.m_transformedPoints[0] = 0.0F;
        this.m_transformedPoints[1] = 0.0F;
        this.m_transformedPoints[2] = currentBitmapWidth;
        this.m_transformedPoints[3] = currentBitmapHeight;
        this.m_matrix.mapPoints(this.m_transformedPoints);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
I was writing code for dragging mechanism which invokes to wait for small period
This is how I get the tags of a body of text. var tags
I'm running a Octopress blog which is based on Jekyll . Now I wanted
I am doing a simple coin flipping experiment for class that involves flipping a
I would like to run a str_replace or preg_replace which looks for certain words
I'm creating a web service to transfer json to an iPhone app. I'm using
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
Hi if i run my project its indicate this logcat error...how to solve this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.