我正在使用图像视图并使用layerDrawable绘制叠加图像.
我已经使用了两个位图原始和myBitmap.
放大后,我不能在正确的位置绘制圆,它被绘制在不同的位置.
我已经使用了两个位图原始和myBitmap.
放大后,我不能在正确的位置绘制圆,它被绘制在不同的位置.
这是我使用的代码,
ImageView view = (ImageView) findViewById(R.id.imageView); view.setOnTouchListener(this); Options options = new BitmapFactory.Options(); options.inScaled = false; original = BitmapFactory.decodeResource(getResources(),R.drawable.mainscreen,options); original= getResizedBitmap(original,width,200); myBitmap = func(original); Resources r = getResources(); layers = new Drawable[2]; layers[0] = new BitmapDrawable(original); layers[1] = new BitmapDrawable(myBitmap); LayerDrawable layerDrawable = new LayerDrawable(layers); view.setImageDrawable(layerDrawable); bitmap = Bitmap.createBitmap(width,200,Config.ARGB_8888); pcanvas = new Canvas(); pcanvas.setBitmap(bitmap); pcanvas.drawBitmap(grayScale,null); public boolean onTouch(View v,MotionEvent rawEvent) { WrapMotionEvent event = WrapMotionEvent.wrap(rawEvent); // ... ImageView view = (ImageView) v; // Dump touch event to log // dumpEvent(event); if (isZoomrequired == false) { x = (int) rawEvent.getX(); y = (int) rawEvent.getY(); r = SettingsActivity.brushsize; pcanvas.drawCircle(x,y,r,mPaint); layers[1] = new BitmapDrawable(bitmap); LayerDrawable layerDrawable = new LayerDrawable(layers); view.setImageDrawable(layerDrawable); } else { // Handle touch events here... switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_DOWN: savedMatrix.set(matrix); start.set(event.getX(),event.getY()); Log.d(TAG,"mode=DRAG"); mode = DRAG; break; case MotionEvent.ACTION_POINTER_DOWN: oldDist = spacing(event); Log.d(TAG,"oldDist=" + oldDist); if (oldDist > 10f) { savedMatrix.set(matrix); midPoint(mid,event); mode = ZOOM; Log.d(TAG,"mode=ZOOM"); } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: mode = NONE; Log.d(TAG,"mode=NONE"); break; case MotionEvent.ACTION_MOVE: if (mode == DRAG) { // ... matrix.set(savedMatrix); matrix.postTranslate(event.getX() - start.x,event.getY() - start.y); } else if (mode == ZOOM) { float newDist = spacing(event); Log.d(TAG,"newDist=" + newDist); if (newDist > 10f) { matrix.set(savedMatrix); float scale = newDist / oldDist; matrix.postScale(scale,scale,mid.x,mid.y); } } break; } view.setImageMatrix(matrix); } return true; // indicate event was handled }
请帮助我放大后,我需要在正确的位置绘制圆形.
任何帮助将不胜感激.