malu05 Posted February 28, 2007 Share Posted February 28, 2007 (edited) This is a little program that currently can view *.cws files thumbnails without using Discreet Combustion.It also saves the Thumbnail as *.bmp file in the appdirI just started coding on this project some few hours ago, but im working towards being able to "hack / patch" the data to make your own custom Thumbnails.The code is still really slow, i would love some feedback on how to improve the speed.Version 1Version 2Version 3 (Latest!)BMP.au3 is needed for this release.can be downloaded Here!If you want to try it out but don't have Combustion i have uploaded a sample *.cws file Here!as an alternative to the source you can also download the *.exe directly Here!expandcollapse popup;CWS Thumbnail Viewer by Malu05 ;;================================================================================ ;Includes ;;================================================================================ #include <Array.au3> #include <file.au3> #include <GUIConstants.au3> #include <string.au3> #include <Color.au3> #include <BMP.au3> ; BMP.au3 can be downloaded from ; http://www.autoitscript.com/forum/index.php?showtopic=27362&hl=bitmap ;;================================================================================ ;HotKey ;;================================================================================ HotkeySet("{ESC}","terminate") HotkeySet("{F1}","credits") HotkeySet("{F2}","Load") ;;================================================================================ ;variables ;;================================================================================ Dim $bvalues[1] Dim $DIF = "8,2258064516129032258064516129032" ; Brightness (255 / 31; Number of Color Values = 255, Number of values = 31) dim $Cola[4], $BMP[10] dim $avalues, $progressbar1,$progressbar2,$Button_1,$Button_2,$backcol1,$renderimage,$finalfile,$Label_1,$Label_2 dim $newload = 0 dim $beginAA,$difAA dim $cocRed=35, $cocGreen=35, $cocBlue=35 ;;================================================================================ ;Initialize (base GUI) ;;================================================================================ $child=GUICreate("cws-peek",128,200) $Button_2 = GUICtrlCreateButton ( "Open New", 2,100) $Button_1 = GUICtrlCreateButton ( "Edit Current", 62,100) GUISetState (@SW_SHOW) Cmdtable() ;;================================================================================ ;Program Loop ;;================================================================================ func Cmdtable() While 1 if $newload = 1 Then CreateThumb() $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 Run('Notepad.exe') ; Will Run/Open Notepad Case $msg = $Button_2 Load() EndSelect Wend Return Endfunc ;==>Cmdtable ;;================================================================================ ;LOAD ;;================================================================================ func Load() GUICtrlDelete($progressbar1) GUICtrlDelete($progressbar2) GUICtrlDelete($backcol1) GUICtrlDelete($Label_1) GUICtrlDelete($Label_2) $cwsfileloc = fileopendialog("Select CWS File",@DesktopDir, "Combustion Workspace (*.cws)", 1) If $cwsfileloc <> "" Then $beginAA = TimerInit() $difAA = (floor(TimerDiff($beginAA))/1000) GUICtrlDelete($renderimage) $testfile = FileGetLongName ($cwsfileloc, 0) $namearray = StringSplit($testfile, "\", 0) $namearrayMax = $namearray[(UBound($namearray)-1)] $finalfile = "thumb_" & $namearrayMax & ".bmp" $Label_1 = GUICtrlCreateLabel( "File: " &$namearrayMax, 4,128) $Label_2 = GUICtrlCreateLabel( $difAA, 4,142, 100,15) ;;-------------------------------------------------------------------------------- ;Find Dimentions ;;-------------------------------------------------------------------------------- Dim $aRecords, $afind = "TNInfo", $search = $cwsfileloc If Not _FileReadToArray($search,$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] If StringInStr($aRecords[$x], $afind) Then $avalues = StringSplit($aRecords[$x], " ") EndIf Next ;MsgBox(0,"Dimentions for: " & $cwsfileloc & " is: ",$avalues[2] & " , " & $avalues[3] ) ;For Debuggin ;;-------------------------------------------------------------------------------- ;Find Data ;;-------------------------------------------------------------------------------- Dim $bRecords, $bfind = "TNData", $search = $cwsfileloc If Not _FileReadToArray($search, $bRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf ;clear Array If UBound($bvalues) > 0 Then For $i = UBound($bvalues) to 0 Step -1 _ArrayDelete( $bvalues, UBound($bvalues)) Next EndIf For $x = 1 to $bRecords[0] Step +1 If StringInStr($bRecords[$x], $bfind) Then _ArrayAdd( $bvalues,$bRecords[$x]) EndIf Next ;;-------------------------------------------------------------------------------- ;Create GUI ;;-------------------------------------------------------------------------------- $progressbar1 = GUICtrlCreateProgress (1,180,128,20) $progressbar2 = GUICtrlCreateProgress (1,160,128,20) $backcol1 = GuiCtrlCreateGraphic(1, (1), ($avalues[2]), ($avalues[3])) GUICtrlSetBkColor(-1,0x000000) $newload = 1 EndIf EndFunc ;;================================================================================ ;Draw Thumbnail ;;================================================================================ Func CreateThumb() $BMP=_BMPCreate($avalues[2],$avalues[3]) For $e = 1 to $avalues[3] Step +1 ;$avalues[3] = hight $difAA = floor((floor(TimerDiff($beginAA))/1000)) GUICtrlSetData ($Label_2, $difAA & " sec. render time") $trashdata = 5 For $i = 1 to $avalues[2] Step +1 ;$avalues[2] = Width GUICtrlSetData ($progressbar1,($e/($avalues[3]/100))) ;GuiCtrlCreateGraphic($i, ($e), (2), (2)) $trashdata = ($trashdata + 3) $test = StringMid($bvalues[$e], $trashdata, 10) $sepvalues = StringSplit($test, "") For $o = 1 to 3 Step +1 GUICtrlSetData ($progressbar2,($i/($avalues[2]/100))) if $sepvalues[$o] = "0" then $Cola[$o] = 0 if $sepvalues[$o] = "1" then $Cola[$o] = $DIF if $sepvalues[$o] = "2" then $Cola[$o] = floor($DIF *2) if $sepvalues[$o] = "3" then $Cola[$o] = floor($DIF *3) if $sepvalues[$o] = "4" then $Cola[$o] = floor($DIF *4) if $sepvalues[$o] = "5" then $Cola[$o] = floor($DIF *5) if $sepvalues[$o] = "6" then $Cola[$o] = floor($DIF *6) if $sepvalues[$o] = "7" then $Cola[$o] = floor($DIF *7) if $sepvalues[$o] = "8" then $Cola[$o] = floor($DIF *8) if $sepvalues[$o] = "9" then $Cola[$o] = floor($DIF *9) if $sepvalues[$o] = ":" then $Cola[$o] = floor($DIF *10) if $sepvalues[$o] = ";" then $Cola[$o] = floor($DIF *11) if $sepvalues[$o] = "<" then $Cola[$o] = floor($DIF *12) if $sepvalues[$o] = "=" then $Cola[$o] = floor($DIF *13) if $sepvalues[$o] = ">" then $Cola[$o] = floor($DIF *14) if $sepvalues[$o] = "?" then $Cola[$o] = floor($DIF *15) if $sepvalues[$o] = "@" then $Cola[$o] = floor($DIF *16) if $sepvalues[$o] = "A" then $Cola[$o] = floor($DIF *17) if $sepvalues[$o] = "B" then $Cola[$o] = floor($DIF *18) if $sepvalues[$o] = "C" then $Cola[$o] = floor($DIF *19) if $sepvalues[$o] = "D" then $Cola[$o] = floor($DIF *20) if $sepvalues[$o] = "E" then $Cola[$o] = floor($DIF *21) if $sepvalues[$o] = "F" then $Cola[$o] = floor($DIF *22) if $sepvalues[$o] = "G" then $Cola[$o] = floor($DIF *23) if $sepvalues[$o] = "H" then $Cola[$o] = floor($DIF *24) if $sepvalues[$o] = "I" then $Cola[$o] = floor($DIF *25) if $sepvalues[$o] = "J" then $Cola[$o] = floor($DIF *26) if $sepvalues[$o] = "K" then $Cola[$o] = floor($DIF *27) if $sepvalues[$o] = "L" then $Cola[$o] = floor($DIF *28) if $sepvalues[$o] = "M" then $Cola[$o] = floor($DIF *29) if $sepvalues[$o] = "N" then $Cola[$o] = floor($DIF *30) if $sepvalues[$o] = "O" then $Cola[$o] = floor($DIF *31) Next $colo = Hex($Cola[1], 2) & Hex($Cola[2], 2) & Hex($Cola[3], 2) _PixelWrite($BMP,$i,$e,$colo) Next Next If FileExists(@ScriptDir & "\" & $finalfile) Then FileDelete(@ScriptDir & "\" & $finalfile) $errorlevel = _BMPWrite($BMP,@ScriptDir & "\" & $finalfile) $renderimage = GUICtrlCreatePic(@ScriptDir & "\" & $finalfile,1,1,$avalues[2], $avalues[3]) ;Msgbox(0,"Stop", "Render Process Complete Process Status; " & $errorlevel) ;for Debuggin If Not WinActive("cws-peek") Then WinFlash('cws-peek',"", 4, 500) $newload = 0 Return EndFunc ;==>CreateThumb ;;================================================================================ ;Terminate ;;================================================================================ func terminate() exit 0 EndFunc ;==>Terminate ;;================================================================================ ;Credits / General Information ;;================================================================================ Func credits() GUICreate("CWS-PEEK Info",150,122,-1,-1,$WS_BORDER) GUICtrlCreateLabel ("*.CWS File Thumbnail Viewer", 5, 5) GUICtrlCreateLabel ("by Mads Hagbarth Lund", 29, 20) GUICtrlCreateLabel ("F1 - Information", 15, 50) GUICtrlCreateLabel ("F2 - Open new", 15, 65) GUICtrlCreateLabel ("ESC - Exit", 15, 80) GUISetState (@SW_SHOW) sleep(4000) GUIDelete(); Return EndFunc ;==>credits Edited March 6, 2007 by malu05 [center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center] Link to comment Share on other sites More sharing options...
i386 Posted February 28, 2007 Share Posted February 28, 2007 Nice job! Will post more comments on it later when I get a chance to look deeper into the code. Spoiler  "...Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like.My crime is that of outsmarting you, something that you will never forgive me for." --The Mentor "Mess with the best, die like the rest!!" -Hackers "This above all to thine own self be true." -William Shakespeare "Corruption is only as corrupted as the individual makes it out to be." -i386    Link to comment Share on other sites More sharing options...
malu05 Posted February 28, 2007 Author Share Posted February 28, 2007 I have just updated the code. Now you can load multiple thumbnails in same session. Fixed 3 render errors that caused strokes on some colors and problems with a few gradient scales. I have added a "Edit Current" button, tho its still not coded so it will currently just open Notepad. Enstead of saving the thumb to thumb.bmp it now saves each file you load to a seperate file in the application dir. Each file is named thumb_$filename.bmp [center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center] Link to comment Share on other sites More sharing options...
_Kurt Posted February 28, 2007 Share Posted February 28, 2007 (edited) Tried it out, it's interesting. Made a small fix on Load() since an error occured each time you attempted to "Cancel" the FileOpenDialog(). func Load() ;FIXED, see first post EndFunc Keep up the good work, Kurt Edited February 28, 2007 by _Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
malu05 Posted February 28, 2007 Author Share Posted February 28, 2007 Tried it out, it's interesting. Made a small fix on Load() since an error occured each time you attempted to "Cancel" the FileOpenDialog(). func Load() .... EndFunc Keep up the good work, Kurt Hehe, yhea forgot about that one, thanks! I also moved the "GUICtrlDelete($renderimage)" so that the image doesnt disapear before a new render session is started and running. Im still a bit confused wethere* its my method that is wrong or how i can improve the speed of the rendering. Normal Thumbnails are 128x96 so its 12288 points it need to go through to complete the render. [center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center] Link to comment Share on other sites More sharing options...
_Kurt Posted February 28, 2007 Share Posted February 28, 2007 Double Post Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
malu05 Posted February 28, 2007 Author Share Posted February 28, 2007 Double Post Dough .. ups [center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center] Link to comment Share on other sites More sharing options...
malu05 Posted March 1, 2007 Author Share Posted March 1, 2007 Updated code with fixed userinterface, filename and render time. Reduced rendertime + processing time due to removal of serval trash loops. Filenames now set correct on large directory path's. [center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center] Link to comment Share on other sites More sharing options...
malu05 Posted March 6, 2007 Author Share Posted March 6, 2007 (edited) Thanks to users i have discovered a critical flaw in the color code and made a critical code update that make the colors display 100% correct. Minor speed fix, preformence is increased by 10%. 2 more hotkey's have been added; *F1 - Credits *F2 - Open New This is the last update for now as i am working on other projects at the moment. Edited March 6, 2007 by malu05 [center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center] 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