如何与屏幕像素画 [英] How to draw with screen pixels

查看:145
本文介绍了如何与屏幕像素画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个Android的雷达中,我将展示在我的Andr​​oid屏幕GPS坐标。所以我要经纬度转换成设备屏幕的像素(X,Y)。要做到这一点我虽然采取屏幕像中心(0,0),改造(纬度,经度)坐标到我的屏幕像素(X,Y)。

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).

问题是,我不知道如何实现这一点。我觉得这个想法sucess,但我不知道屏幕是如何工作的,像素坐标等。

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.

任何提示请?

感谢

推荐答案

Android支持很多不同的屏幕方向。正因为如此,它的 HIGHLY轻率以曾经使用绝对像素。

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

完成你正在尝试做的最好的方法可能是通过的OpenGL ES API

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;

希望这有助于!

这篇关于如何与屏幕像素画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆