AtlasOnEarth
AtlasOnEarth

Reputation: 83

x must be < bitmap.width()

I'm building an app that takes a picture, displays the picture and then once tapped, returns the color of the picture wherever it was tapped.

It gets as far as the tap before it crashes. I get the error that x must be < bitmap.width()

As far as my understanding goes, if I'm clicking within the bitmap and gaining the coordinate, how can it be greater than the bitmap.width()?

I'll post my code below and see if anyone can help me make sense of what I'm doing wrong.

http://pastebin.com/scwiuM4w

Upvotes: 1

Views: 878

Answers (1)

Alexander
Alexander

Reputation: 48272

Your onTouchEvent returns x, y within the Activity not within your ImageView.

See from Activity.onTouchEvent help: Called when a touch screen event was not handled by any of the views under it. This is most useful to process touch events that happen outside of your window bounds, where there is no view to receive it.

Upvotes: 1

Related Questions