views:

45

answers:

1

I have a simple question which keeps me thinking for a few hours now.

Assume a canvas which is rotated by a specific (known) degree. I want to get the screen coordinates of a bitmap I have drawn on the rotated canvas. To achieve this, I need the canvas' clip bounds. This would be no problem for a non-rotated canvas. But it keeps giving me strange values for the rotated case. To be honest, I'm not really sure, what they're supposed to be for a rotated canvas, as top and bottom can't be simple Integer values representing the distance of the currently viewable part on the y-axis to the top and the bottom of the canvas. The same applies to left and right. So what do these values mean to me and how can I use them to get the screen coordinates?

Looking at the Android source didn't help, as they're using a native_getClipBounds() method which I couldn't find anywhere...

A: 

Not really an answer, but it was turning into something too long for a comment.

You say you know the angle. Why don't you plot the bitmap on paper and calculate the coordinates of the rotated bitmap's corners and the extent of the bounding box of the rotated bitmap (the red rectangle) and see which of those (if any) agree with the numbers you're getting from Canvas.getClipBounds().

alt text

ChrisF
The problem is, that the canvas I use, is for a map so it's really big, especially compared to the currently viewable part. No chance to scale it down to papersize without loosing too much informations... But thanks for the fast response! :)
ubuntudroid
@ubuntudroid - Well you don't have to be exactly to scale! Just draw the shapes and write the coordinates of the corners down.
ChrisF
Ah, it seems, I got you wrong! That's a good idea - I'll try that tomorrow!
ubuntudroid