#include <GDIPlus.au3>
_GDIPlus_Startup()
$sImage1 = 'capcha.png'
$sImage2 = 'capcha0.png'
$hSource = _GDIPlus_ImageLoadFromFile($sImage1)
$Size = _GDIPlus_GetImageDimension($hSource)
$hDestination = _GDIPlus_CreateBitmapFromScan0($Size[0] * 3, $Size[1] * 3, 0, _GDIPlus_GetImagePixelFormat($hSource)) ; увеличиваем картинку
$hGraphics = _GDIPlus_ImageGetGraphicsContext($hDestination)
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hSource, 0, 0, $Size[0] * 3, $Size[1] * 3)
_GDIPlus_ImageSaveToFile($hDestination, $sImage2)
_GDIPlus_GraphicsDispose($hGraphics)
_GDIPlus_ImageDispose($hDestination)
_GDIPlus_ImageDispose($hSource)
_GDIPlus_Shutdown()
$ocr_filename = 'capcha' ; текстовый файл
ShellExecuteWait('D:\ocr\tesseract.exe', $sImage2 & ' ' & $ocr_filename & ' -l', @SW_MINIMIZE)
$sText = FileRead($ocr_filename & '.txt')
MsgBox(0, 'Заголовок', $sText)
Func _GDIPlus_CreateBitmapFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0)
Local $Ret = DllCall($ghGDIPDll, 'uint', 'GdipCreateBitmapFromScan0', 'int', $iWidth, 'int', $iHeight, 'int', $iStride, 'int', $iPixelFormat, 'ptr', $pScan0, 'ptr*', 0)
If (@error) Or ($Ret[0]) Then
Return SetError(1, 0, 0)
EndIf
Return $Ret[6]
EndFunc ;==>_GDIPlus_CreateBitmapFromScan0
Func _GDIPlus_GetImageDimension($hImage)
Local $Ret = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hImage, 'float*', 0, 'float*', 0)
If (@error) Or ($Ret[0]) Then
Return SetError(1, 0, 0)
EndIf
Local $Result[2]
$Result[0] = $Ret[2]
$Result[1] = $Ret[3]
Return $Result
EndFunc ;==>_GDIPlus_GetImageDimension
Func _GDIPlus_GetImagePixelFormat($hImage)
Local $Ret = DllCall($ghGDIPDll, 'uint', 'GdipGetImagePixelFormat', 'ptr', $hImage, 'uint*', 0)
If (@error) Or ($Ret[0]) Then
Return SetError(1, 0, 0)
EndIf
Return $Ret[2]
EndFunc ;==>_GDIPlus_GetImagePixelFormat