Jump to content

Use tga pictures in AutoIt only


funkey
 Share

Recommended Posts

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=d9d57870af3b4da43dc4e343ff8bf265e988fb30

Example for using in a GUI:

#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 ;==>_GUICtrlSetTgaImage

Greetings

funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

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 to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...