函数名

getScreenPixel(x1,y1,x2,y2)

函数介绍

方法名称:获取指定范围内的像素数组

参数说明:当x1,y1,x2,y2全部为0表示获取全屏像素值

x1:整数型,区域左上X坐标 

y1:整数型,区域左上Y坐标 

x2:整数型,区域右下X坐标 

y2:整数型,区域右下Y坐标


返回值:w,h,arr,其中w,h是获取范围的长宽,arr是返回的数组,如果w,h小于0则表明失败

函数例子

--当前测试在720x1280模式下

function printRGB(color)
  local r,g,b = colorToRGB(color)
  print("col:".."=>"..r..","..g..","..b)
end

local w,h,arr = getScreenPixel(0,0,0,0)

print("image size:"..w..","..h)
local x = 567
local y = 1231
local color = arr[y * w + (x + 1)]
local cc = getPixelColor(x,y)
printRGB(cc)
printRGB(color)