发帖
充值
 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
28 1

c++编写SO供懒人精灵读取屏幕数据插件源码

源码分享 20858 28 2021-8-19 23:28:45
采用C++编写SO给懒人调用API



  1. #include <map>
  2. #include <string>
  3. #include <vector>
  4. #include <list>
  5. #include <sys/socket.h>
  6. #include <netinet/in.h>
  7. #include <linux/if.h>
  8. #include <linux/sockios.h>
  9. #include <arpa/inet.h>
  10. #include <semaphore.h>
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14. #include <unistd.h>
  15. #include <sys/wait.h>
  16. #include <sys/types.h>
  17. #include <fcntl.h>
  18. #include <android/log.h>
  19. #include <pthread.h>

  20. extern "C"
  21. {
  22.         #include <math.h>
  23.         #include <lua.h>
  24.         #include <lauxlib.h>
  25.         #include <lualib.h>
  26.         #include <lr.h>
  27. };
  28. using namespace std;

  29. void  LOGD(const char* fmt,...){
  30.     char str[4096];
  31.     va_list ap;
  32.     int ret;
  33.     va_start(ap, fmt);
  34.     ret = vsnprintf(str, 4096, fmt, ap);
  35.     if (ret >= 4096)
  36.         return;
  37.     __android_log_print(ANDROID_LOG_DEBUG, "LR", "%s",str);
  38. }

  39. static int lrGetPixel(lua_State *L){
  40.         int ret = 0;
  41.         luaL_checktype(L, 1, LUA_TNUMBER);//参数安全检查
  42.         luaL_checktype(L, 2, LUA_TNUMBER);
  43.         int x = (int)lua_tonumber(L,1);
  44.         int y = (int)lua_tonumber(L,2);
  45.         int w,h;
  46.         int* ptr = (int*)lrGetScreenPixel(0,0,0,0,&w,&h);//获取屏幕数据
  47.         LOGD("ret:%p %d %d",ptr,w,h);
  48.         if(ptr){
  49.                 if(x < w && y < h){
  50.                         uint8_t* argb = (uint8_t*)&ptr[y * w + x];
  51.                         lua_pushinteger(L,argb[0]);
  52.                         lua_pushinteger(L,argb[1]);
  53.                         lua_pushinteger(L,argb[2]);
  54.                         ret = 3;
  55.                 }
  56.                 lrRelease(ptr);//一定要记得释放内存
  57.         }
  58.         return ret;
  59. }


  60. static const struct luaL_Reg R[] = {
  61.     {"lrGetPixel" ,  lrGetPixel},
  62.     {NULL, NULL}
  63. };

  64. extern "C"{
  65.         LR_API int luaopen_liblrapi(lua_State*L)
  66.         {
  67.                 luaL_newlib(L, R);
  68.                 LOGD("load lrapilib");
  69.                  return 1;
  70.         }
  71. }
复制代码



c 读取屏幕数据插件源码.zip

229.76 KB, 阅读权限: 10, 下载次数: 93

售价: 10 金钱  [记录]

使用道具 举报

2021-11-25 21:04:25
膜拜创始人
2021-12-17 21:35:27
⁶⁶⁶⁶⁶     卧槽⁶⁶⁶⁶⁶⁶    666 ⁶⁶⁶⁶⁶⁶    ⁶⁶⁶⁶⁶⁶     ⁶⁶66⁶⁶⁶⁶     ⁶⁶⁶⁶⁶⁶卧槽    ⁶⁶666⁶⁶⁶⁶⁶⁶⁶⁶⁶卧槽   ⁶⁶⁶⁶⁶⁶    ⁶⁶66⁶⁶⁶⁶     卧槽⁶⁶⁶⁶⁶⁶     ⁶6666⁶⁶666牛逼!
2021-12-23 16:21:43
牛逼666......
2022-1-5 19:37:35
这是做什么用的呢
2022-1-5 19:48:33
厉害,顶顶定
2022-1-20 10:14:47
2022-4-18 15:42:37

膜拜创始人,用做什么滴?
2022-4-20 14:15:52

6666666666666666666666666
2022-4-28 18:08:53

6666666666666666666666666
您需要登录后才可以回帖 立即登录
高级模式
123下一页
源码分享