FrioneL
FrioneL

Reputation: 941

How to draw with screen pixels

I'm developing an android "radar" in which I will show a gps coordinates in my android screen. So I have to convert the latitude and longitude to the pixels (x, y) of the device screen. To do that I though in take the center of the screen like (0, 0) and transform the coordinates of (lat, lng) to my screen pixels (x, y).

The problem is that I dont know how to implement this. I think the idea would sucess but I dont know how the screen works, the pixel coordinates, etc.

Any tips pls?

Thanks

Upvotes: 1

Views: 643

Answers (1)

Codeman
Codeman

Reputation: 12375

Android supports many different screen orientations. Because of this, it is HIGHLY UNADVISED to EVER use absolute pixels.

The best way to accomplish what you are trying to do is likely through the OpenGL ES API.

If all you want to do is get the "center" of the display, you can use the following:

int centX = WindowManager.getDefaultDisplay().getWidth() / 2;
int centY = WindowManager.getDefaultDisplay().getHeight() / 2;

Hope this helps!

Upvotes: 1

Related Questions