#Region ;**** 参数创建于 ACNWrapper_GUI ****
#PRE_UseX64=n
#PRE_Res_requestedExecutionLevel=None
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GDIPlus.au3>
#include <Array.au3>
Local $sImageFile = @ScriptDir & '\2016.png'
;~ Global $aAryImage = _BitmapGetPixel($sImageFile, '[0,0][6,6]')
Global $aAryImage = _BitmapGetPixel($sImageFile, '[401,598][679,876]')
;~ _ArrayDisplay($aAryImage)
;~ Global $aAryImage = _BitmapGetColorToArray($sImageFile, '[0,66][103,189]')
$Form1 = GUICreate('Form1', 600, 600)
$pixel_size = 1
For $i = 0 To UBound($aAryImage) - 1;行
For $x = 0 To UBound($aAryImage, 2) - 1
$Label1 = GUICtrlCreateLabel($aAryImage[$i][$x], $x * $pixel_size, $i * $pixel_size, $pixel_size, $pixel_size)
GUICtrlSetBkColor(-1, '0x' & $aAryImage[$i][$x])
GUICtrlSetColor(-1, 0xffffff)
Next
Next
GUISetState()
While GUIGetMsg() <> -3
WEnd
Func _BitmapGetPixel($__hBitmap, $__coordinate)
Local $__begin_time = TimerInit()
$__coordinate = StringRegExp($__coordinate, '\[(.+?)\]', 3)
Local $__posi = StringSplit($__coordinate[0], ',', 2)
Local $__size = StringSplit($__coordinate[1], ',', 2)
_GDIPlus_Startup()
Local $hImage = _GDIPlus_ImageLoadFromFile($__hBitmap)
If @error Then
_GDIPlus_Shutdown()
Return SetError(1)
EndIf
Local $i_Width = _GDIPlus_ImageGetWidth($hImage)
Local $i_Height = _GDIPlus_ImageGetHeight($hImage)
Local $__x = $__posi[0]
Local $__y = $__posi[1]
Local $iIW = $__size[0] - $__posi[0]
Local $iIH = $__size[1] - $__posi[1]
ConsoleWrite(StringFormat('%s ][ x=%s y=%s w=%s h=%s \n', '_bitmapGetColor', $__x, $__y, $iIW, $iIH))
Local $tBitmapData = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iIW, $iIH, $GDIP_ILMREAD, $GDIP_PXF32ARGB)
Local $Scan0 = DllStructGetData($tBitmapData, 'Scan0')
Local $v_BufferA = DllStructCreate('byte[' & $i_Width * $i_Height * 4 & ']', $Scan0)
Local $sAllPixels = DllStructGetData($v_BufferA, 1)
$v_BufferA = 0
_GDIPlus_BitmapUnlockBits($hImage, $tBitmapData)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
$sAllPixels = StringTrimLeft($sAllPixels, 2)
Local $aRet[$iIH][$iIW], $__PixelBits
For $c = 0 To $iIH - 1;行
For $r = 0 To $iIW - 1
$aRet[$c][$r] = _BitmapStrGetPixel($sAllPixels, ($__x + $r) & ',' & ($c + $__y), $i_Width, $i_Height)
Next
Next
#cs
For $i = 0 To $iIH - 1;行
$__xPixel = ($__x * 8) + 1;色点开始位置,X轴
$__yPixel = ($__y + $i) * $i_Width * 8;色点开始位置,Y轴
$__wPixel = ($iIW + 1) * 8;整图.色点宽度
$__rPixel = StringMid($sAllPixels, $__xPixel + $__yPixel, $__wPixel);截取的色点行
$__rPixel = StringRegExpReplace($__rPixel, '(..)(..)(..)(..)', '${3}${2}${1}');颜色格式转换
;~ $__PixelBits &= $__rPixel
;~ ConsoleWrite(StringFormat('%s ][ sPixel=%s wPixel=%s\n', '_bitmapGetColor', $__xPixel, $__wPixel))
$__rPixel = StringRegExp($__rPixel, '(.{6})', 3);提取所有色点
If @error Then Return SetError(2)
For $r = 0 To $iIW - 1;列
$aRet[$i][$r] = $__rPixel[$r]
Next
Next
#ce
$__rPixel = 0
ConsoleWrite(StringFormat('%s ][ %s \n', '_bitmapGetColor', TimerDiff($__begin_time)))
Return $aRet
EndFunc ;==>_BitmapGetPixel
Func _BitmapStrGetPixel($__str, $__coordinate, $__width, $__height);字符串提取坐标
$__coordinate = StringRegExp($__coordinate, '(\d+),(\d+)', 3);坐标转换为数组
$__x = $__coordinate[0]
$__y = $__coordinate[1]
$__wPixel = ($__width) * 8;一行的色点字符长度
$__xPixel = ($__x * 8) + 1;色点开始位置,X轴
$__yPixel = $__y * $__wPixel;色点开始位置,Y轴
$__cPixel = StringMid($__str, $__xPixel + $__yPixel, 8);截取的色点行
$__cPixel = StringRegExpReplace($__cPixel, '(..)(..)(..)(..)', '${3}${2}${1}');颜色格式转换
Return $__cPixel
EndFunc ;==>_BitmapStrGetPixel