Image Selection Area

We are developing image mapping for education. The teacher can add a question with an image. The answer to the diagram is based on the image chosen by the teacher.

For instance:

  • Which region is a region having gold. enter image description here then the teacher can select the correct answer (region B and E) by clicking on the answer of the circuit in the picture enter image description here

Question:

  • As a teacher, how to perform a circuit response with a touch on the image and what value is stored in the database
  • As a student, how a student can click the correct answer

Can anyone suggest or help me?

I am new to android ..

Thank!

+4
source share
1 answer

. - . - "". . "" (.. Png). ImageView. "" .

 final ImageView imageView = ...; //TODO: bind imageView
 imageView.setImageResource(R.drawable.original_image);
 final Bitmap map = ...; //TODO: load map bitmap
 imageView.setOnTouchListener((v, event) -> {
     final int x = event.getX();
     final int y = event.getY();
     final float scale = ...//TODO calc image scale;
     final int realX = (int) (x * scale);
     final int realY = (int) (y * scale);
     final int color = map.getPixel(realX, realY);
     if (color == Color.RED) {
         //Correct answer!
     } else {
        //something else
     }
});

Map image .

+5

Source: https://habr.com/ru/post/1677975/


All Articles