#include <GDIP.au3>
#include <Color.au3>
Global $delta = 10 ; допустимое отклонение цвета фона от образца
$sImage = @ScriptDir & '\7678.png'
_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile($sImage)
Global $iWidth = _GDIPlus_ImageGetWidth($hImage)
Global $iHeight = _GDIPlus_ImageGetHeight($hImage)
$iBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
Global $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($iBitmap)
Global $Ground = 0x0402FC
$xLeft = 0
$xRight = 0
$x = 0
$sTring1 = ''
While $x < $iWidth - 1
While _BlackLine($x) And $x < $iWidth - 1
$x += 1
WEnd
$xLeft = $x
While Not _BlackLine($x) And $x < $iWidth
$x += 1
WEnd
$xRight = $x - 1
$hClone = _GDIPlus_BitmapCloneArea($hBitmap, $xLeft, 0, $xRight - $xLeft + 1, $iHeight, $GDIP_PXF24RGB)
$countstring = _SegmentMatrix($hClone)
Switch $countstring
Case '745'
$sTring1 &= '1'
Case '1044'
$sTring1 &= '2'
Case '843'
$sTring1 &= '3'
Case '741'
$sTring1 &= '4'
Case '1243'
$sTring1 &= '5'
Case '938'
$sTring1 &= '6'
Case '949'
$sTring1 &= '7'
Case '1039'
$sTring1 &= '8'
Case '1040'
$sTring1 &= '9'
Case '1037'
$sTring1 &= '0'
EndSwitch
_GDIPlus_ImageDispose($hClone)
WEnd
_GDIPlus_ImageDispose($hImage)
_WinAPI_DeleteObject($iBitmap)
_WinAPI_DeleteObject($hBitmap)
_GDIPlus_Shutdown()
MsgBox(0, 'Заголовок', $sTring1)
Func _SegmentMatrix($hBitmap1)
Local $tMap1, $Width1, $Height1, $bData1, $bData2, $bData3
$Width1 = _GDIPlus_ImageGetWidth($hBitmap1)
$Height1 = _GDIPlus_ImageGetHeight($hBitmap1)
$tMap1 = _GDIPlus_BitmapLockBits($hBitmap1, 0, 0, $Width1, $Height1, $GDIP_ILMREAD, $GDIP_PXF32ARGB)
$bData1 = DllStructGetData(DllStructCreate('byte[' & ($Width1 * $Height1 * 4) & ']', DllStructGetData($tMap1, 'Scan0')), 1)
_GDIPlus_BitmapUnlockBits($hBitmap1, $tMap1)
_GDIPlus_BitmapDispose($hBitmap1)
$bData2 = StringMid($bData1, 1, StringLen($bData1) / 2)
$bData3 = StringMid($bData1, StringLen($bData1) / 2)
$aTemp1 = StringRegExp($bData2, '(FCFEFC)FF', 3)
$aTemp2 = StringRegExp($bData3, '(FC0204)FF', 3)
Return Ubound($aTemp1) - 1 & Ubound($aTemp2) - 1
EndFunc ;==>_SegmentMatrix
Func _BlackLine($stolb)
Local $color
For $i = 0 To $iHeight - 1
$color = '0x' & Hex(_GDIPlus_BitmapGetPixel($hBitmap, $stolb, $i), 6)
If Abs(_ColorGetRed($color) - _ColorGetRed($Ground)) > $delta Or _
Abs(_ColorGetGreen($color) - _ColorGetGreen($Ground)) > $delta Or _
Abs(_ColorGetBlue($color) - _ColorGetBlue($Ground)) > $delta Then Return False
Next
Return True
EndFunc ;==>_BlackLine