Android imageview get pixel color from scaled image

前端 未结 2 1124
醉酒成梦
醉酒成梦 2021-02-01 10:55

My home automation app has a feature where people can upload images to their phone with floorplans and dashboards that they can use to control their home automation software. I

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-01 11:29

    I figured it out. I replaced

     xCoord = Integer.valueOf((int)ev.getRawX());
     yCoord = Integer.valueOf((int)ev.getRawY());
    

    with

     Matrix inverse = new Matrix();
     v.getImageMatrix().invert(inverse);
     float[] touchPoint = new float[] {ev.getX(), ev.getY()};
     inverse.mapPoints(touchPoint);
     xCoord = Integer.valueOf((int)touchPoint[0]);
     yCoord = Integer.valueOf((int)touchPoint[1]);
    

提交回复
热议问题