funkey Posted September 6, 2013 Share Posted September 6, 2013 Hello,i made this TGA functions for the help forum, but to find it better and with some bugfixes and a better example I post it now here in the example scripts forum. I made an AutoIt version and a DLL version of the functions '_loadTarga' and '_freeTarga'. DLL version is needed for speed, AutoIt version is to show how it works in AutoIt only. You can download it form here: http://www.autoit.de/index.php?page=Attachment&attachmentID=23532&h=d9d57870af3b4da43dc4e343ff8bf265e988fb30Example for using in a GUI:expandcollapse popup#AutoIt3Wrapper_UseX64=n ;for DLL version #include <ButtonConstants.au3> ;~ #include "TGA DLL.au3" #include "TGA AutoIt.au3" Global $hGui = GUICreate("TGA example", 450, 300) Global $nPic = GUICtrlCreatePic("", 10, 10, 100, 100) Global $nButton1 = GUICtrlCreateButton("", 320, 30, 100, 100, $BS_BITMAP) Global $nButton2 = GUICtrlCreateButton("", 320, 140, 100, 100, $BS_BITMAP) _GUICtrlSetTgaImage($nPic, @ScriptDir & "\dirt2.tga") _GUICtrlSetTgaImage($nButton1, @ScriptDir & "\1.tga") _GUICtrlSetTgaImage($nButton2, @ScriptDir & "\font.tga") GUISetState() Do Until GUIGetMsg() = -3 Func _GUICtrlSetTgaImage($nCtrlID, $sTgaFile) Local $tTGA = DllStructCreate($tagTGA) Local $hBitmap_TGA = _loadTarga($tTGA, $sTgaFile) If @error Then Return SetError(1, 0, 0) Exit EndIf Switch _WinAPI_GetClassName(GUICtrlGetHandle($nCtrlID)) Case "Static" _WinAPI_DeleteObject(GUICtrlSendMsg($nCtrlID, 370, 0, $hBitmap_TGA)) _freeTarga($tTGA) Case "Button" _WinAPI_DeleteObject(GUICtrlSendMsg($nCtrlID, 247, 0, $hBitmap_TGA)) _WinAPI_DeleteDC(DllStructGetData($tTGA, "dc")) ; do not _freetarga, hBitmap is needed for buttons Case Else _freeTarga($tTGA) Return SetError(2, 0, 0) EndSwitch Return 1 EndFunc ;==>_GUICtrlSetTgaImageGreetingsfunkey Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
Yashied Posted September 6, 2013 Share Posted September 6, 2013 Copying image data pixel by pixel is not the best way. Why not use FreeImage? My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
funkey Posted September 6, 2013 Author Share Posted September 6, 2013 How do you think FreeImage does this. I think it does it the same way, but I don't know. FreeImage is a great, but huge library file. I know file sizes are no problem nowadays, but I like to keep things small and I wanted to show how to do it in AutoIt as mentioned above. Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. 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