关于百度定位获取到的BD2坐标对WGC坐标的偏移解决方案

最近在做百度定位,发现获取到的坐标跟GPS取到的坐标有很大偏差,上网查很多资料说是百度获取到的BD2坐标是经过加密的,网上很多GPS坐标转BD2坐标的算法,但是我要的是GPS坐标而不是BD2坐标,百度了许久终于找到一个免费的API接口,http://api.zdoz.net/bd2wgs.aspx?lat=34.121&lng=115.21212。使用方法也很简单,把获取到的百度BD2坐标放进上面的网址,访问就得到GPS坐标的json字符串啦。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用 Win32 API 实现窗口抓屏的示例代码: ```c++ #include <windows.h> int main() { // 获取窗口句柄 HWND hWnd = FindWindow(NULL, TEXT("窗口标题")); // 获取窗口矩形 RECT rect; GetWindowRect(hWnd, &rect); // 计算窗口大小 int width = rect.right - rect.left; int height = rect.bottom - rect.top; // 创建设备上下文 HDC hdcScreen = GetDC(NULL); HDC hdcWindow = GetDC(hWnd); HDC hdcMem = CreateCompatibleDC(hdcScreen); HBITMAP hBitmap = CreateCompatibleBitmap(hdcScreen, width, height); SelectObject(hdcMem, hBitmap); // 截取窗口图像 BitBlt(hdcMem, 0, 0, width, height, hdcWindow, 0, 0, SRCCOPY); // 保存图像到文件 BITMAPINFOHEADER bih; bih.biSize = sizeof(BITMAPINFOHEADER); bih.biWidth = width; bih.biHeight = height; bih.biPlanes = 1; bih.biBitCount = 24; bih.biCompression = BI_RGB; bih.biSizeImage = 0; bih.biXPelsPerMeter = 0; bih.biYPelsPerMeter = 0; bih.biClrUsed = 0; bih.biClrImportant = 0; BITMAPFILEHEADER bfh; bfh.bfType = 0x4d42; bfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + width * height * 3; bfh.bfReserved1 = 0; bfh.bfReserved2 = 0; bfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); HANDLE hFile = CreateFile(TEXT("screenshot.bmp"), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); DWORD dwWritten; WriteFile(hFile, &bfh, sizeof(BITMAPFILEHEADER), &dwWritten, NULL); WriteFile(hFile, &bih, sizeof(BITMAPINFOHEADER), &dwWritten, NULL); BYTE* pBits = new BYTE[width * height * 3]; GetDIBits(hdcMem, hBitmap, 0, height, pBits, (BITMAPINFO*)&bih, DIB_RGB_COLORS); WriteFile(hFile, pBits, width * height * 3, &dwWritten, NULL); delete[] pBits; CloseHandle(hFile); // 释放资源 DeleteObject(hBitmap); DeleteDC(hdcMem); ReleaseDC(hWnd, hdcWindow); ReleaseDC(NULL, hdcScreen); return 0; } ``` 其中,`FindWindow` 函数用于获取窗口句柄,`GetWindowRect` 函数用于获取窗口矩形,`CreateCompatibleDC` 函数用于创建设备上下文,`CreateCompatibleBitmap` 函数用于创建位图,`SelectObject` 函数用于选择位图到设备上下文,`BitBlt` 函数用于截取窗口图像,`GetDIBits` 函数用于获取位图数据,`CreateFile` 函数用于创建文件,`WriteFile` 函数用于写入文件,`DeleteObject` 函数用于删除位图,`DeleteDC` 函数用于删除设备上下文,`ReleaseDC` 函数用于释放设备上下文。 请注意,该示例代码只能在 Windows 系统下编译和运行。如果需要在其他系统下进行窗口抓屏,需要使用相应的 API 实现。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值