Sand Posted August 19, 2008 Posted August 19, 2008 Hi all i want to do this but i dont want the image to be blured i need it to be exat Zoom of the origin - can you tell me how to do it ? change the image with whatever image you need my idea is to make a program with wich i open a image with all characters and specify where each char ends so my program will cut each char and generate an array with the chars after someone helps me showing the zoomed part normaly i will need to read the specified image bytes colors and put them in array expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <WinAPI.au3> $FileName = @ScriptDir & "\small.png"; $width = 790 $height = 450 $last_char_pos = 0 $start_pos = 0 $current_char = 33 $zoom = 16 $hMain = GUICreate("Font character extractor", 800, 500) ; Labels $hCharLabel = GUICtrlCreateLabel("Current char: " & Chr ($current_char), 8, 460, 90) ; Buttons $b_left = GUICtrlCreateButton("<", 100, 460, 50) $b_right = GUICtrlCreateButton(">", 150, 460, 50) $b_next = GUICtrlCreateButton("Apply", 210, 460, 60) $b_generate = GUICtrlCreateButton("Generate", 270, 460, 60) ; Display the window GUISetState(@SW_SHOW, $hMain) _GDIPlus_Startup() ; Load Image $Image = _GDIPlus_ImageLoadFromFile($FileName) $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hMain) Func Draw () _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $Image, $start_pos, 0, $width/$zoom, $height/$zoom, 5, 5, $width, $height) ;_WinAPI_stretchBlt($hGraphic,5,5,$width,$height,$Image,$start_pos,0,$width/$zoom,$height/$zoom,$SRCCOPY) EndFunc ;Author(s) : Prog@ndy, after _WinAPI_BitBlt Func _WinAPI_stretchBlt($hDestDC, $iXDest, $iYDest, $iWidth, $iHeight, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iROP) Local $aResult $aResult = DllCall("GDI32.dll", "int", "StretchBlt", "hwnd", $hDestDC, "int", $iXDest, "int", $iYDest, "int", $iWidth, "int", $iHeight, _ "hwnd", $hSrcDC, "int", $iXSrc, "int", $iYSrc,"int",$iWidthSrc,"int",$iHeightSrc, "int", $iROP) If @error Then Return SetError(@error, 0, False) Return $aResult[0] <> 0 EndFunc ;==>_WinAPI_BitBlt ; Run the GUI until the dialog is closed Draw () While 1 $msg = GUIGetMsg() Select Case $msg = $b_generate Case $msg = $b_left If ($start_pos > 0) Then $start_pos = $start_pos - 1 Draw () EndIf Case $msg = $b_right If ($start_pos < 100) Then $start_pos = $start_pos + 1 Draw () EndIf Case $msg = $b_next If ($current_char < 127) Then $current_char = $current_char + 1 if ($last_char_pos < $start_pos) Then $last_char_pos = $start_pos GUICtrlSetData ($hCharLabel, "Current char: " & Chr($current_char)) EndIf Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Func OnAutoItExit() _GDIPlus_GraphicsDispose ($hGraphic) _GDIPlus_ImageDispose ($Image) _GDIPlus_Shutdown() EndFunc
martin Posted August 19, 2008 Posted August 19, 2008 Hi all i want to do this but i dont want the image to be blured i need it to be exat Zoom of the origin - can you tell me how to do it ? change the image with whatever image you need my idea is to make a program with wich i open a image with all characters and specify where each char ends so my program will cut each char and generate an array with the chars after someone helps me showing the zoomed part normaly i will need to read the specified image bytes colors and put them in array expandcollapse popup#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <WinAPI.au3> $FileName = @ScriptDir & "\small.png"; $width = 790 $height = 450 $last_char_pos = 0 $start_pos = 0 $current_char = 33 $zoom = 16 $hMain = GUICreate("Font character extractor", 800, 500) ; Labels $hCharLabel = GUICtrlCreateLabel("Current char: " & Chr ($current_char), 8, 460, 90) ; Buttons $b_left = GUICtrlCreateButton("<", 100, 460, 50) $b_right = GUICtrlCreateButton(">", 150, 460, 50) $b_next = GUICtrlCreateButton("Apply", 210, 460, 60) $b_generate = GUICtrlCreateButton("Generate", 270, 460, 60) ; Display the window GUISetState(@SW_SHOW, $hMain) _GDIPlus_Startup() ; Load Image $Image = _GDIPlus_ImageLoadFromFile($FileName) $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hMain) Func Draw () _GDIPlus_GraphicsDrawImageRectRect ($hGraphic, $Image, $start_pos, 0, $width/$zoom, $height/$zoom, 5, 5, $width, $height) ;_WinAPI_stretchBlt($hGraphic,5,5,$width,$height,$Image,$start_pos,0,$width/$zoom,$height/$zoom,$SRCCOPY) EndFunc ;Author(s) : Prog@ndy, after _WinAPI_BitBlt Func _WinAPI_stretchBlt($hDestDC, $iXDest, $iYDest, $iWidth, $iHeight, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iROP) Local $aResult $aResult = DllCall("GDI32.dll", "int", "StretchBlt", "hwnd", $hDestDC, "int", $iXDest, "int", $iYDest, "int", $iWidth, "int", $iHeight, _ "hwnd", $hSrcDC, "int", $iXSrc, "int", $iYSrc,"int",$iWidthSrc,"int",$iHeightSrc, "int", $iROP) If @error Then Return SetError(@error, 0, False) Return $aResult[0] <> 0 EndFunc ;==>_WinAPI_BitBlt ; Run the GUI until the dialog is closed Draw () While 1 $msg = GUIGetMsg() Select Case $msg = $b_generate Case $msg = $b_left If ($start_pos > 0) Then $start_pos = $start_pos - 1 Draw () EndIf Case $msg = $b_right If ($start_pos < 100) Then $start_pos = $start_pos + 1 Draw () EndIf Case $msg = $b_next If ($current_char < 127) Then $current_char = $current_char + 1 if ($last_char_pos < $start_pos) Then $last_char_pos = $start_pos GUICtrlSetData ($hCharLabel, "Current char: " & Chr($current_char)) EndIf Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Func OnAutoItExit() _GDIPlus_GraphicsDispose ($hGraphic) _GDIPlus_ImageDispose ($Image) _GDIPlus_Shutdown() EndFunc To stop the blurring you have to copy each pixel in the source to a square the size of $zoom x $zoom. This function does it but it is horribly slow, and might still not give you want you want without futher processing to improve the contrast. Func Draw() For $x = 0 To $width / $zoom For $y = 0 To $height / $zoom For $m = 1 To $zoom For $n = 1 To $zoom _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $Image, $x, $y, 1, 1, $zoom * $x + $m, $zoom * $y + $n, 1, 1) Next Next Next Next EndFunc ;==>Draw Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now