Sunday, June 4, 2017

Image touch selection area

Leave a Comment

We are developing image mapping for education. The teacher can add question with image. The schema answer is based on the image touched selection by the teacher.

For example;

  • Which are the area represent district that having gold. enter image description here then the teacher can choose the correct answer(B and E district) by pressing the schema answer at picture enter image description here

The question are

  1. As a teacher how to do the schema answer with touching the image and what value to store into database
  2. As a student how student can press the correct answer

Anyone can suggest or help me?

I'm newbie in android..

Thanks!

1 Answers

Answers 1

You should use two different image. First image is original image. Second image is "map" image. Map image contains zones of different colors. "Map" image must be saved to file with lossless compression (i.e. png). Original image shows in ImageView. "Map" image must be decoded to Bitmap.

 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 Sorry for my english.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment