English 中文(简体)
甲型六氯环己烷
原标题:android draw line on scaled and transformed image on canvas

我难以在信道上打下大幅和变形的形象,这对我能够掌握形象的转变来说是好的,但是如果图像被扩大(或外出)的话,那么,这个图像会利用 f子产生出意料的粉碎。 在我从事油漆应用工作时,我确实更了解这方面的情况,因此,我需要你的帮助,我已经从奥古角度搜寻,但没有发现任何uck。

here is the images 1st is default working properly and in second moved image working properly drew the line properly

enter image description here enter image description here

而在第三点,图像分布不适当,如果从顶部/左角开始,那么这个线的点就不同于这里。

“entergraph

if you need for code then say it I ll edit the question

最佳回答

在经过许多执行之后,我找到解决办法。

This is my code for drawing in onDraw()

@Override
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.save();
    canvas.translate(mPosX, mPosY);
    canvas.scale(mScaleFactor, mScaleFactor);

    canvas.drawBitmap(MoveImageTestActivity.bmp, 0,0,null);
    if(mScaleFactor!=1.f)
        canvas.restore();

    if(isDrawing)
        canvas.drawPath(tempPath,get_paint());

    if(mScaleFactor==1.f)
        canvas.restore();
}

在此,你必须检查恢复信道的比额表因数值。 如果比额表系数值为1.f,而图像只是在线/波段之后恢复,如果比额表系数不等于1.f(fault),那么,在使用指线抽取时间时,就会恢复信标1。

这里是我关于托库(Touch)的法典

@Override
public boolean onTouchEvent(MotionEvent ev) {
    mScaleDetector.onTouchEvent(ev);
    final int action = ev.getAction();
    switch (action & MotionEvent.ACTION_MASK) {
    case MotionEvent.ACTION_DOWN: {
        final float x = ev.getX();
        final float y = ev.getY();

        if(isDrawing){
            float dx = ev.getX();
            float dy = ev.getY();;

            if(mScaleFactor==1.f){
                dx = ev.getX() - mPosX;
                dy = ev.getY() - mPosY;
            }
            tempPath = new Path();
            tempPath.moveTo(dx,dy);
        }else{
            mLastTouchX = x;
            mLastTouchY = y;
            // Save the ID of this pointer
            mActivePointerId = ev.getPointerId(0);
        }
        break;
    }

    case MotionEvent.ACTION_MOVE: {
        // Find the index of the active pointer and fetch its position
        if(isDrawing){
            float dx = ev.getX();
            float dy = ev.getY();;

            if(mScaleFactor==1.f){
                dx = ev.getX() - mPosX;
                dy = ev.getY() - mPosY;
            }
            tempPath.lineTo(dx,dy);
        }else{
            final int pointerIndex = ev.findPointerIndex(mActivePointerId);
            final float x = ev.getX(pointerIndex);
            final float y = ev.getY(pointerIndex);

            final float dx = x - mLastTouchX;
            final float dy = y - mLastTouchY;

            mPosX += dx;
            mPosY += dy;

            mLastTouchX = x;
            mLastTouchY = y;
        }
        break;
    }
    case MotionEvent.ACTION_UP: {
        points.clear();
        mActivePointerId = INVALID_POINTER_ID;
        break;
    }

    case MotionEvent.ACTION_CANCEL: {
        mActivePointerId = INVALID_POINTER_ID;
        break;
    }

    case MotionEvent.ACTION_POINTER_UP: {
        if(!isDrawing){
            // Extract the index of the pointer that left the touch sensor
            final int pointerIndex = (action & MotionEvent.ACTION_POINTER_INDEX_MASK) >> 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;
    }
    }
    invalidate();
    return true;
}
问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签