ileandros Posted May 29, 2012 Share Posted May 29, 2012 Hello there, I have a simple image viewer. It read urls from IE given, gets all the images and show them. My only problem is that it doesnt read the .TGA images. Is it able to make it read the .TGA images even if i dont program required installed for .TGA files? Actually i know that it is possible since i have a simillar program in java but is it possible to make that in AutoIt??? Thanks! I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
ileandros Posted May 30, 2012 Author Share Posted May 30, 2012 Any ideas people??? Bump I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
Shaggi Posted May 31, 2012 Share Posted May 31, 2012 Read or show the image? And, elaborate show. Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG Link to comment Share on other sites More sharing options...
ileandros Posted May 31, 2012 Author Share Posted May 31, 2012 Read and show...It's a image viewer. You got any ideas??? I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
BrewManNH Posted May 31, 2012 Share Posted May 31, 2012 I don't think that Windows can view TGA files natively, so I don't think you'll be able to do it in AutoIt without some sort of external program being used. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
Blue_Drache Posted May 31, 2012 Share Posted May 31, 2012 Brew is correct. I had to install an extension to view TGA natively in Windows' Icon view and to be able to build thumbs for them. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
ileandros Posted June 5, 2012 Author Share Posted June 5, 2012 (edited) I know that. As i already said that i have a image viewer in java witch does read/show the .TGA. But since there is not way in AutoIt fine. Thanks Edited June 5, 2012 by ileandros I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted June 6, 2012 Share Posted June 6, 2012 SDL_image can read TGA. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include "SDL.au3" #include "SDL_image.au3" ;Select file $sRet = FileOpenDialog("Select .tga file to open", "", "TARGA files (*.tga)") If @error Then Exit 0* ConsoleWrite("blah blah" & @LF) ;Init stuff _SDL_Init($_SDL_INIT_VIDEO) _SDL_Init_image(@ScriptDir & "") ;Load picture $pImage = _IMG_Load($sRet) ;Get size $tImage = DllStructCreate($tagSDL_SURFACE, $pImage) $iWidth = DllStructGetData($tImage, "w") $iHeight = DllStructGetData($tImage, "h") ;Something to display on $pScreen = _SDL_GuiCreate("Some title", $iWidth, $iHeight, 0, 0) ;Copy to screen _SDL_BlitSurface($pImage, 0, $pScreen, 0) ;Show _SDL_Flip($pScreen) ;Close window as normal While 1 Sleep(10) WEnd .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
ileandros Posted June 7, 2012 Author Share Posted June 7, 2012 Seems cool but i got a problem. I got a problem with dl. Internet Explorer cannot display the webpage... Is this only my problem or is there a problem with the link??? I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
ileandros Posted June 7, 2012 Author Share Posted June 7, 2012 Talking about SDL UDF I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted June 7, 2012 Share Posted June 7, 2012 It seems whatever host I choose it go down in a year or so MVP's has more space, so now I was able to attach the zip to the post directly. You can download from there now. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
ileandros Posted June 7, 2012 Author Share Posted June 7, 2012 Ok fine now. The script above seems to work fine. But after choosing a image (.TGA) at the OpenDialog i got a Autoit3.exe System Error: "The program can't starte because SDL.dll is missing from ur computer. Try reinstalling the program to fix this problem." Does it run to you??? After that i got an error in the ConsoleWrite: C:UsersLeandroDesktoplean.au3UDFSDL_image.au3 (48) : ==> Subscript used with non-Array variable.: $Struct = DllStructCreate("ubyte;ubyte;ubyte", $pTemp[0]) $Struct = DllStructCreate("ubyte;ubyte;ubyte", $pTemp^ ERROR I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted June 9, 2012 Share Posted June 9, 2012 (edited) Did you copy the dll to the script folder? That message means that the dll is missing. You need SDL.au3 SDL.dll SDL_image.au3 SDL_image.dll at the very least. It runs for me. Edited June 9, 2012 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
ProgAndy Posted June 9, 2012 Share Posted June 9, 2012 (edited) You can also use FreeImage. These snippets are in C, but the AutoIt-code should be similar. When you have the HBITMAP, use Edit: Here is an example: expandcollapse popup#AutoIt3Wrapper_usex64=n #include<WinAPI.au3> #include<FreeImage.au3> #include <GUIConstants.au3> ; modify these variables Global Const $sFreeImageDLL = "E:UDFFreeImageFreeImage.dll" Global Const $sTIFF_File = @ScriptDir & "test.tif" _FreeImage_LoadDLL($sFreeImageDLL) #region - GUI Create GUICreate('Display', 400, 400) $iPic = GUICtrlCreatePic("", 0, 0, 400, 400) GUISetState() #endregion ; Load image, create thumbnail, maximum 400x400px $pDIBOrg = _FreeImage_Load($FIF_TIFF, $sTIFF_File); $pDIB = _FreeImage_MakeThumbnail($pDIBOrg, 400) _FreeImage_Unload($pDIBOrg) ; create windows HBITMAP for picture control $hDC = _WinAPI_GetDC(GUICtrlGetHandle($iPic)) $hBitmap = DllCall('gdi32.dll', 'ptr', 'CreateDIBitmap', 'hwnd', $hDC, 'ptr', _FreeImage_GetInfoHeader($pDIB), 'dword', 0x04, 'ptr', _FreeImage_GetBits($pDIB), 'ptr', _FreeImage_GetInfo($pDIB), "uint", 0) $hBitmap = $hBitmap[0] _WinAPI_ReleaseDC(GUICtrlGetHandle($iPic), $hDC) ; Free FreeImage image _FreeImage_Unload($pDIB); ; set HBITMAP to control _GUICtrlStatic_SetImage($iPic, $hBitmap) #region - GUI SelectLoop While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd #endregion ; #FUNCTION# ==================================================================================================================== ; Name...........: _GUICtrlStatic_SetImage ; Description ...: Sets a HBITMAP to a static control like image or label ; Syntax.........: _GUICtrlStatic_SetImage($iCtrlId, $hBitmap) ; Parameters ....: $iCtrlId - CtrlId or handle of Control in the current process ; $hBitmap - Pointer top Windows HBITMAP ; Return values .: Success - 1 ; Failure - 0 and set @error: ; |1 - invalid $pSource ; |1 - invalid $pSource ; Author ........: ProgAndy, Zedna ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _GUICtrlStatic_SetImage($iCtrlId, $hBitmap) Local Const $STM_SETIMAGE = 0x0172 Local Const $IMAGE_BITMAP = 0 Local Const $SS_BITMAP = 0xE Local Const $GWL_STYLE = -16 If IsHWnd($iCtrlId) Then If WinGetProcess($iCtrlId) <> @AutoItPID Then Return SetError(1,0,0) Else $iCtrlId = GUICtrlGetHandle($iCtrlId) If Not $iCtrlId Then Return SetError(2,0,0) EndIf ; set SS_BITMAP style to control Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE) If @error Then Return SetError(3, 0, 0) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP)) If @error Then Return SetError(4, 0, 0) Local $oldBmp = DllCall("user32.dll", "handle", "SendMessageW", "hwnd", $iCtrlId, "int", $STM_SETIMAGE, "wparam", $IMAGE_BITMAP, "handle", $hBitmap) If @error Then Return SetError(5, 0, 0) If $oldBmp[0] Then _WinAPI_DeleteObject($oldBmp[0]) Return 1 EndFunc Edited June 9, 2012 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
ileandros Posted June 9, 2012 Author Share Posted June 9, 2012 (edited) AdmiralAlkex, yes i copied it at the script folder. I also tryied to delete and dl it again but still same problem. Are you sure that at the dl package are everything required?Saying because u have problem with the link.I dont know whats wrong. After that message it shows this error in the console of scite C:UsersLeandroDesktoplean.au3UDFSDL_image.au3 (48) : ==> Subscript used with non-Array variable.: $Struct = DllStructCreate("ubyte;ubyte;ubyte", $pTemp[0]) $Struct = DllStructCreate("ubyte;ubyte;ubyte", $pTemp^ ERROR Edit: All the examples works fine though..... Edited June 9, 2012 by ileandros I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
ileandros Posted June 9, 2012 Author Share Posted June 9, 2012 You can also use FreeImage. These snippets are in C, but the AutoIt-code should be similar. When you have the HBITMAP, use Edit: Here is an example: expandcollapse popup#AutoIt3Wrapper_usex64=n #include<WinAPI.au3> #include<FreeImage.au3> #include <GUIConstants.au3> ; modify these variables Global Const $sFreeImageDLL = "E:UDFFreeImageFreeImage.dll" Global Const $sTIFF_File = @ScriptDir & "test.tif" _FreeImage_LoadDLL($sFreeImageDLL) #region - GUI Create GUICreate('Display', 400, 400) $iPic = GUICtrlCreatePic("", 0, 0, 400, 400) GUISetState() #endregion ; Load image, create thumbnail, maximum 400x400px $pDIBOrg = _FreeImage_Load($FIF_TIFF, $sTIFF_File); $pDIB = _FreeImage_MakeThumbnail($pDIBOrg, 400) _FreeImage_Unload($pDIBOrg) ; create windows HBITMAP for picture control $hDC = _WinAPI_GetDC(GUICtrlGetHandle($iPic)) $hBitmap = DllCall('gdi32.dll', 'ptr', 'CreateDIBitmap', 'hwnd', $hDC, 'ptr', _FreeImage_GetInfoHeader($pDIB), 'dword', 0x04, 'ptr', _FreeImage_GetBits($pDIB), 'ptr', _FreeImage_GetInfo($pDIB), "uint", 0) $hBitmap = $hBitmap[0] _WinAPI_ReleaseDC(GUICtrlGetHandle($iPic), $hDC) ; Free FreeImage image _FreeImage_Unload($pDIB); ; set HBITMAP to control _GUICtrlStatic_SetImage($iPic, $hBitmap) #region - GUI SelectLoop While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd #endregion ; #FUNCTION# ==================================================================================================================== ; Name...........: _GUICtrlStatic_SetImage ; Description ...: Sets a HBITMAP to a static control like image or label ; Syntax.........: _GUICtrlStatic_SetImage($iCtrlId, $hBitmap) ; Parameters ....: $iCtrlId - CtrlId or handle of Control in the current process ; $hBitmap - Pointer top Windows HBITMAP ; Return values .: Success - 1 ; Failure - 0 and set @error: ; |1 - invalid $pSource ; |1 - invalid $pSource ; Author ........: ProgAndy, Zedna ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; =============================================================================================================================== Func _GUICtrlStatic_SetImage($iCtrlId, $hBitmap) Local Const $STM_SETIMAGE = 0x0172 Local Const $IMAGE_BITMAP = 0 Local Const $SS_BITMAP = 0xE Local Const $GWL_STYLE = -16 If IsHWnd($iCtrlId) Then If WinGetProcess($iCtrlId) <> @AutoItPID Then Return SetError(1,0,0) Else $iCtrlId = GUICtrlGetHandle($iCtrlId) If Not $iCtrlId Then Return SetError(2,0,0) EndIf ; set SS_BITMAP style to control Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE) If @error Then Return SetError(3, 0, 0) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP)) If @error Then Return SetError(4, 0, 0) Local $oldBmp = DllCall("user32.dll", "handle", "SendMessageW", "hwnd", $iCtrlId, "int", $STM_SETIMAGE, "wparam", $IMAGE_BITMAP, "handle", $hBitmap) If @error Then Return SetError(5, 0, 0) If $oldBmp[0] Then _WinAPI_DeleteObject($oldBmp[0]) Return 1 EndFunc Nice work I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted June 10, 2012 Share Posted June 10, 2012 AdmiralAlkex, yes i copied it at the script folder. I also tryied to delete and dl it again but still same problem. Are you sure that at the dl package are everything required?Saying because u have problem with the link.I dont know whats wrong. After that message it shows this error in the console of scite C:\Users\Leandro\Desktop\lean.au3\UDF\SDL_image.au3 (48) : ==> Subscript used with non-Array variable.: $Struct = DllStructCreate("ubyte;ubyte;ubyte", $pTemp[0]) $Struct = DllStructCreate("ubyte;ubyte;ubyte", $pTemp^ ERROR Edit: All the examples works fine though..... Well, the UDF do has some "issues" (I have been wanting to rewrite it complete for some time), but this problem happens much more often than i expect. Does it work if you put it in the same folder as the examples? Try changing the SDL_init line to _SDL_Init($_SDL_INIT_VIDEO, @ScriptDir & "\") (or wherever you put the sdl.dll) Also, could you post the complete output from the console? That way I can try and reproduce the error on the same Windows and AutoIt you have... .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
ileandros Posted June 10, 2012 Author Share Posted June 10, 2012 That fixed it!!! Now works like a charm. I already have a program installed in my cpu for .TGA files so i dont know if it will work without it but i guess it will. Thanks I feel nothing.It feels great. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted June 12, 2012 Share Posted June 12, 2012 You can also use FreeImage. These snippets are in C, but the AutoIt-code should be similar. When you have the HBITMAP, use Edit: Here is an example: Interesting example and UDF. Using that and the gdi+ to sdl example I made this: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <FreeImage.au3> #Include "SDL.au3" #Include "SDL_gfx.au3" #region ;Examples $hWnd1 = GUICreate("Testing _BitmapToSurface", 457, 266, 0, 0) GUISetState() EnvSet("SDL_WINDOWID", $hWnd1) _SDL_Init($_SDL_INIT_VIDEO, @ScriptDir & "") _FreeImage_LoadDLL(@ScriptDir & "FreeImage.dll") _SDL_Startup_gfx(@ScriptDir & "") $pScreen = _SDL_SetVideoMode(457, 266, 32, $_SDL_SWSURFACE) $pDIBOrg = _FreeImage_Load($FIF_PNG, @ScriptDir & "SDL_logo.png") _BlitFreeImageToSurface($pDIBOrg, $pScreen) _SDL_Flip($pScreen) ; Free FreeImage image _FreeImage_Unload($pDIBOrg); Do Until GUIGetMsg() = -3 _SDL_Quit() #endregion #region ;_BlitFreeImageToSurface Func _BlitFreeImageToSurface($pDIB, $pSurface) $iWidth = _FreeImage_GetWidth($pDIB) $iHeight = _FreeImage_GetHeight($pDIB) $pTemp = _SDL_CreateRGBSurfaceFrom(_FreeImage_GetBits($pDIB), $iWidth, $iHeight, _FreeImage_GetBPP($pDIB), _FreeImage_GetPitch($pDIB), 0, 0, 0, 0) $pRotated = _SDL_rotozoomSurfaceXY($pTemp, 360, 1, -1, 0) ;Flip image. FreeImage stores upside down evidently... _SDL_BlitSurface($pRotated, _SDL_Rect_Create(0, 1, $iWidth, $iHeight), $pSurface, 0) ;Remove black line at top _SDL_FreeSurface($pRotated) _SDL_FreeSurface($pTemp) EndFunc #endregion Had to mess around a little to flip the image and remove an extra black line but it seems to work fine. That fixed it!!! Now works like a charm. I already have a program installed in my cpu for .TGA files so i dont know if it will work without it but i guess it will. Thanks No other programs are needed, only the dll. It's standalone like AutoIt. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface 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