silverhawk1842 Posted March 30, 2011 Share Posted March 30, 2011 Below is a snippit of my code,expandcollapse popup;---begin pre script excerpt #include <file.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> $phone='a' $title='0' ;---end pre script excerpt $files=_FileListToArray(@ScriptDir&'\output\'&$phone&'\',$title&'*.jpg',1) _GDIPlus_Startup() $win2=GUICreate("cropper") $win2bg = GUICtrlCreatePic('',0,0,1,1,$win2) $cropbar=GUICtrlCreatePic(@ScriptDir&'\res\cropbar.gif',0,0,200,1,$win2) ;GUISwitch($GUI) for $i=1 to $files[0] if $i<4 then ;GUICtrlSetData($status,"cropping top of thumbnail") $img=_GDIPlus_ImageLoadFromFile(@ScriptDir&'\output\'&$phone&'\'&$files[$i]) $w=_GDIPlus_ImageGetWidth($img)/10 $h=_GDIPlus_ImageGetHeight($img)/10 _GDIPlus_ImageDispose($img) ;msgbox(0,FileExists(@ScriptDir&'\output\'&$phone&'\'&$files[$i]),@ScriptDir&'\output\'&$phone&'\'&$files[$i]) winmove($win2,default,default,$w,$h) GUISetState(@SW_SHOW,$win2) GUICtrlSetPos($cropbar,0,0,$w,1) GUICtrlSetPos($win2bg,0,0,$w,$h) GUICtrlSetImage($win2bg,@ScriptDir&'\output\'&$phone&'\'&$files[$i]) $show=1 While $show<>0 $msg = GUIGetMsg($win2) Select Case $msg = $GUI_EVENT_MOUSEMOVE $a=GUIGetCursorInfo($win2) GUICtrlSetPos($cropbar,0,$a[1]) case $msg = $GUI_EVENT_PRIMARYDOWN $a=GUIGetCursorInfo($win2) $croppos=$a[1]*10 GUISetState(@SW_HIDE,$win2) $show=2 case $msg = $GUI_EVENT_PRIMARYUP if $show=2 then $show=0 Exit EndSelect WEnd EndIf NextHere are the possible outcomes: (of only close and reopen)1234 //close to the desired output5678910here are my resource images/res/cropbar.gifand/output/a/00.jpgThe basis for my script is to display a dialogue, showing a scaled down thumbnail of an image to be cropped. the red cropbar indicates the position to be cropped.It has worked perfectly about 2 times (like the image indicated, but without a border on cropbar)the image comes from an image magic script and then goes back to imagemagic for processing, i have no problem with this.Please tell me what is going wrong.Win XP Pro sp3Autoit version: 3,3,6,1 Link to comment Share on other sites More sharing options...
silverhawk1842 Posted March 30, 2011 Author Share Posted March 30, 2011 (edited) defining the outcomes1 no cropbar2 no images & nothing resizing3 no images, but with resizing4 close to the desired output but there is a border on the cropbar5 no images, but with some resizing6 bad image7 no images, with some resizing, i dont know what cropbar is doing8 1 image loaded9 no images with scrollbars10 both images, scrollbars, and fat cropbar11 i dont know hat is going on!12 some wierd blue thing on top Edited March 30, 2011 by silverhawk1842 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 30, 2011 Moderators Share Posted March 30, 2011 silverhawk1842,Welcome to the AutoIt forum. I found a few syntax errors scattered through the script (look for <<<<<<<<<< lines) and I changed your .gif image into a .jpg - I have never had much luck with .gifs in a Pic control. This seems to work for me - I altered the size as your base image was far to small to make a sensible GUI if reduced by a factor of 10:expandcollapse popup;---begin pre script excerpt #include <file.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> $phone = 'a' $title = '0' ;---end pre script excerpt $files = _FileListToArray(@ScriptDir & '\', $title & '*.jpg', 1) _GDIPlus_Startup() $win2 = GUICreate("cropper") $win2bg = GUICtrlCreatePic('', 0, 0, 1, 1);, $win2) ; syntax <<<<<<<<<<<<<<<< Why GUI handle ? $cropbar = GUICtrlCreatePic(@ScriptDir & '\cropbar.jpg', 0, 0, 200, 1);, $win2) ; syntax <<<<<<<<< Why GUI handle ? ;GUISwitch($GUI) For $i = 1 To $files[0] If $i < 4 Then ;GUICtrlSetData($status,"cropping top of thumbnail") $img = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\' & $files[$i]) $w = Ceiling(_GDIPlus_ImageGetWidth($img) / 2) $h = Ceiling(_GDIPlus_ImageGetHeight($img) / 2) _GDIPlus_ImageDispose($img) WinMove($win2, "", Default, Default, $w, $h) ; syntax <<<<<<<<<<<<<<<<<<< added "" for "text" parameter GUICtrlSetPos($cropbar, 0, 0, $w, 1) GUICtrlSetPos($win2bg, 0, 0, $w, $h) GUICtrlSetImage($win2bg, @ScriptDir & '\' & $files[$i]) GUISetState() $show = 1 While $show <> 0 $msg = GUIGetMsg() ; syntax <<<<<<<<<<<<<<<<<<<<< Why GUI handle? Select Case $msg = $GUI_EVENT_MOUSEMOVE $a = GUIGetCursorInfo($win2) GUICtrlSetPos($cropbar, 0, $a[1]) Case $msg = $GUI_EVENT_PRIMARYDOWN $a = GUIGetCursorInfo($win2) $croppos = $a[1] * 10 GUISetState(@SW_HIDE, $win2) $show = 2 Case $msg = $GUI_EVENT_PRIMARYUP If $show = 2 Then $show = 0 Exit EndSelect WEnd EndIf NextDoes it work for you now? Please ask if you have any questions. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
silverhawk1842 Posted March 30, 2011 Author Share Posted March 30, 2011 (edited) Thank you for helping, I used the GUI Handle because I have 2 GUIs and call GUISwitch($win1) shortly after initiating $win2. Anyway, I changed the cropbar.gif to a jpg and added the quotes for winmove, and I am still getting the random issues. The jpeg dimensions are normally 1700x2200 1175x850 1461x969 1750x2300 ... divided by 2 is still too big to get the jest of the image. do you think they are too big for autoit? Edited March 30, 2011 by silverhawk1842 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 30, 2011 Moderators Share Posted March 30, 2011 silverhawk1842,I used the GUI Handle because...But in none of those cases is the GUI handle required by AutoIt - go and look in the Help file. You are putting the random GUI handle value into the "style" parameter of the Pic controls which is quite possibly the reason for the errors you are getting. And the only parameter you can use with GUIGetMsg is a simple "1"! do you think they are too big for autoit?Certainly not if you are factoring them. Perhaps you could adjust your factoring to get a roughly "standard" size so you do not have wildly differing reduction values.I am still getting the random issuesDo these occur when different images are displayed? What happens if you use just the one image and run the loop several times using only that image? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
silverhawk1842 Posted March 30, 2011 Author Share Posted March 30, 2011 (edited) Thanks, That makes sense. The GUIHandle is a semi-random integer, thus, assigning the controls a random (and sometimes non-existent) style. This was the reason for all the odd outcomes. I feel stupid. Edited March 31, 2011 by silverhawk1842 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 30, 2011 Moderators Share Posted March 30, 2011 silverhawk1842, I take it that all is now well? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
silverhawk1842 Posted March 31, 2011 Author Share Posted March 31, 2011 We are good, Thanks! Link to comment Share on other sites More sharing options...
silverhawk1842 Posted April 1, 2011 Author Share Posted April 1, 2011 I found a bug, or at least something that needs to be mentioned somewhere. Autoit cannot display images in CMYK colorspace, if you are having problems when you try to load an image and are getting "0" returned, convert your image to RGB colorspace. Link to comment Share on other sites More sharing options...
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