Android Bitmap.getPixel()非常不准确

Android Bitmap.getPixel()非常不准确,android,bitmap,getpixel,Android,Bitmap,Getpixel,项目概述:有两张图片。单击我的应用程序中的顶部图像我使用cat pic,它会将底部图像背景设置为您单击位置上像素的颜色 问题是:背景颜色与单击位置的像素颜色不匹配,有时是随机着色的,有时是关闭一些阴影。它很柔软 这是主要的java代码: 下面是Main.XML: 是什么让你认为人的手指能够准确地点击触摸屏上的特定像素?我使用了鼠标点击,当然我从一个浮点输入到了一个整数,丢失了数据,但在我从醉酒的门廊醒来之后。从昨晚的派对上,我才意识到这可能是因为我缩放了图像,而位图getpixel坐标没有缩放到

项目概述:有两张图片。单击我的应用程序中的顶部图像我使用cat pic,它会将底部图像背景设置为您单击位置上像素的颜色

问题是:背景颜色与单击位置的像素颜色不匹配,有时是随机着色的,有时是关闭一些阴影。它很柔软

这是主要的java代码:

下面是Main.XML:


是什么让你认为人的手指能够准确地点击触摸屏上的特定像素?我使用了鼠标点击,当然我从一个浮点输入到了一个整数,丢失了数据,但在我从醉酒的门廊醒来之后。从昨晚的派对上,我才意识到这可能是因为我缩放了图像,而位图getpixel坐标没有缩放到屏幕上。我将测试这份报告,然后返回stackedoverflow,看它是否有效。如果你想要我们制作一个teamview并编写代码,因为我将为用户制作面部识别软件电话
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Button;
import android.widget.ImageView;
public class ColorRead extends Activity 
implements OnTouchListener{
 Integer myColor;
 String TAG;
 Bitmap bMap,bMap2;
 ImageView image,image2;
 Button BTN;
 MotionEvent mEvent;
 Integer touchX,touchY;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle Icicle) {
        super.onCreate(Icicle);
        setContentView(R.layout.main);
        bMap = BitmapFactory.decodeResource(getResources(), R.drawable.catpic);
        image2 = (ImageView) findViewById(R.id.bitmap2);
        image = (ImageView) findViewById(R.id.bitmap);
        image.setImageBitmap(bMap);
        image.setOnTouchListener(this);
    }
    public void scanForColor(int xMouse, int yMouse)
    {
     myColor = bMap.getPixel(xMouse,yMouse);
     Log.i(TAG, " R:"+Color.red(myColor)+" G:"+Color.green(myColor)+" B:"+Color.blue(myColor));
     image2.setBackgroundColor(myColor);
    }

 @Override
 public boolean onTouch(View v, MotionEvent e) {
  Integer id = v.getId();
  switch(id)
  {
  case R.id.bitmap:
   if(e.getAction() == MotionEvent.ACTION_DOWN)
         {
                 touchX = (int)e.getX();
                 touchY = (int)e.getY();
         }
   scanForColor(touchX,touchY);
         Log.i(TAG,touchX.toString());
         break;
    default:
     break;
  }
        return false;
 }
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<ImageView android:id="@+id/bitmap"  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:src="@drawable/catpic"
    />
    <ImageView android:id="@+id/bitmap2"  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:src="@drawable/catpic"
    />
    <Button android:id="@+id/button"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
    android:text="@string/myButton"
    />

</LinearLayout>