BMP/JPG Dans un EXE ? Topic is solved

Poser vos questions de programmation en AutoHotkey
User avatar
SmX1
Posts: 3
Joined: 20 Feb 2021, 18:19

BMP/JPG Dans un EXE ?

20 Feb 2021, 19:09

Bonjour,

Je souhaite intégrer une image dans mon interface (gui).

J'utilise pour cela:

Code: Select all

Gui, Add, Picture, x1 y1 w98 h98 , Avatar.jpg
Mais dès que je déplace mon fichier...cela part en cacahuette
(normal étant donné que le code se réfère a une image qui n'est plus la).

Comment intégrer cette image dans mon EXE ?

J'ai tenté avec ResHack, d'ajouter l'image comme ressource, simple, mais dans mon code, comment faire appel a cette ressource ?

J'ai tenté avec Image2Include (image convertie "Create_Avatar_bmp.ahk") mais après suis perdu.

Il y a pas mal de topic en anglais (langue que je n'ai pas eu a l'école) sur le sujet et plus j'essaye de les comprendre, plus je m'enfonce....
garry
Posts: 2630
Joined: 22 Dec 2013, 12:50

Re: BMP/JPG Dans un EXE ?

21 Feb 2021, 13:41

Example avec fileinstall

Code: Select all

#Warn
#NoEnv
setworkingdir,%a_scriptdir%
fileinstall,avatar.jpg,avatar.jpg,1
Gui, Add, Picture, x1 y1 w200 h-1 ,avatar.jpg
Gui,show
return
Guiclose:
Exitapp



Example du SKAN ,
essayer script-2
script-1 pour créer image et ajoutez les données du fichier 'pngdata.txt' à fichier-2 pngdata=


https://autohotkey.com/board/topic/85709-base64enc-base64dec-base64-encoder-decoder/
Fichier-1

Code: Select all

;================== SCRIPT-1 =========================================================
;-https://autohotkey.com/board/topic/85709-base64enc-base64dec-base64-encoder-decoder/
SetWorkingDir, %A_ScriptDir%

File := a_scriptdir . "\test.png"
FileGetSize, Size, %File%
FileRead, Bin, *c %File%
Base64enc( PNGDATA, Bin, Size )
aa:=pngdata
fileappend,%aa%,%a_scriptdir%\pngdata.txt,utf-8
Return  

Base64enc( ByRef OutData, ByRef InData, InDataLen ) {
 DllCall( "Crypt32.dll\CryptBinaryToString" ( A_IsUnicode ? "W" : "A" )
        , UInt,&InData, UInt,InDataLen, UInt,1, UInt,0, UIntP,TChars, "CDECL Int" )
 VarSetCapacity( OutData, Req := TChars * ( A_IsUnicode ? 2 : 1 ) )
 DllCall( "Crypt32.dll\CryptBinaryToString" ( A_IsUnicode ? "W" : "A" )
        , UInt,&InData, UInt,InDataLen, UInt,1, Str,OutData, UIntP,Req, "CDECL Int" )
Return TChars
} 
;============== END SCRIPT-1 =========================================================
Fichier-2

Code: Select all

;================== SCRIPT-2 =========================================================
;-https://autohotkey.com/board/topic/85709-base64enc-base64dec-base64-encoder-decoder/
SetWorkingDir, %A_ScriptDir%
GoSub, LoadPNGDATA
Bytes := Base64Dec( BIN, PNGDATA )
VarZ_Save( BIN, Bytes, "test.png" )
VarSetcapacity( PNGDATA, 0 )

Gui, Margin, 0, 0
Gui, Add, Picture,x1 y1 w100 h-1,test.png
Gui, Show
Return                             
;------------------

GuiClose:
 ExitApp
;==================

Base64dec( ByRef OutData, ByRef InData ) {
 DllCall( "Crypt32.dll\CryptStringToBinary" ( A_IsUnicode ? "W" : "A" ), UInt,&InData
        , UInt,StrLen(InData), UInt,1, UInt,0, UIntP,Bytes, Int,0, Int,0, "CDECL Int" )
 VarSetCapacity( OutData, Req := Bytes * ( A_IsUnicode ? 2 : 1 ) )
 DllCall( "Crypt32.dll\CryptStringToBinary" ( A_IsUnicode ? "W" : "A" ), UInt,&InData
        , UInt,StrLen(InData), UInt,1, Str,OutData, UIntP,Req, Int,0, Int,0, "CDECL Int" )
Return Bytes
}

VarZ_Save( ByRef Data, DataSize, TrgFile ) { ; By SKAN http://www.autohotkey.com/community/viewtopic.php?t=45559
 hFile :=  DllCall( "_lcreat", ( A_IsUnicode ? "AStr" : "Str" ),TrgFile, UInt,0 )
 IfLess, hFile, 1, Return "", ErrorLevel := 1
 nBytes := DllCall( "_lwrite", UInt,hFile, UInt,&Data, UInt,DataSize, UInt )
 DllCall( "_lclose", UInt,hFile )
Return nBytes
}

LoadPNGDATA:
pngdata=
(Ltrim join`r`n
iVBORw0KGgoAAAANS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1FQh1aW3
yeG7RsQh01kTKUtzoNyTSUUNTK1lxu8ejoazcqEAmyD1lIE3iziQzW2KBQTCjW9b
aHo1VrLOEeahvZ+ve41zhY0lFOc5vTI9fApPrWtWtTxDMwgIdXpIoxUrI94x6rVX
GXGYgyT8Trkwn6t92UyzCEgCObsZnSEXFv1keAO6XagpmyEt2/HwPgzGft8c+A+0
GgHcVWVNv87sD3UwYMkstImHkI7isM4JPqh52DUb+iqmDQhgbXIEhBOx98dD1JxT
1W0Z0nKiADjp2SV4s4irdy0wI9qEAG4bOBYxu0k7OJWU55COP89ZDtaUcLjr88BL
x/uLdDYigE+ElybN4M9D7HSlNo7X89wvqtbHTgVQNaD1CWO47cdSmP5sRgAfCvLL
+/Xj+9f30YiXRtFDJwpojHNWNfD8pTt+92jszC0ItpEKl1dSbt2gOnr3njOE6D9A
AEu307+CqarO98vxf4RgPkS5k/4jBP+QXggeTy8Ej6cXgsfTC8Hj6YXg8fRC8Hh6
IXg8vRA8nl4IHk8vBI+nF4LH0wvB4+mF4PH0QvB4eiF4PL0QPJ5eCB5PLwSPp/8R
BHdt3H40/Y/MwVOTJmXKc1P2f4rkDrxjAo/KAAAAAElFTkSuQmCC
)
return
;==================== END script-2 ====================================================
User avatar
SmX1
Posts: 3
Joined: 20 Feb 2021, 18:19

Re: BMP/JPG Dans un EXE ?

21 Feb 2021, 20:03

Oui, j'ai vu les posts de "SKAN" bcp y font référence,

mais il me semble que file install, justement installe le/les fichier(s) sur la machine qui exécute...

Je souhaite vraiment que mon projet soit une app portable.

Je vais quand même creuser sur cette voie, merci a toi.
User avatar
joedf
Posts: 7898
Joined: 29 Sep 2013, 17:08
Facebook: J0EDF
Google: +joedf
GitHub: joedf
Location: Canada
Contact:

Re: BMP/JPG Dans un EXE ?

21 Feb 2021, 20:13

Tu pourrais d'inspirer de la technique utilisée dans Ahk2Exe :
https://github.com/AutoHotkey/Ahk2Exe/blob/47b466807f8ad82e54018f62e9a62b4e1e8dba60/Ahk2Exe.ahk#L175

Code: Select all

;@Ahk2Exe-IgnoreBegin
Gui, Add, Pic, x29 y16 w240 h78, %A_ScriptDir%\logo.png
;@Ahk2Exe-IgnoreEnd
/*@Ahk2Exe-Keep
gosub AddPicture
*/

;...

/*@Ahk2Exe-Keep
AddPicture:
; Code based on http://www.autohotkey.com/forum/viewtopic.php?p=147052
Gui, Add, Text, x29 y16 w240 h78 +0xE hwndhPicCtrl
;@Ahk2Exe-AddResource logo.png
hRSrc := DllCall("FindResource", "ptr", 0, "str", "LOGO.PNG", "ptr", 10, "ptr")
sData := DllCall("SizeofResource", "ptr", 0, "ptr", hRSrc, "uint")
hRes  := DllCall("LoadResource", "ptr", 0, "ptr", hRSrc, "ptr")
pData := DllCall("LockResource", "ptr", hRes, "ptr")
hGlob := DllCall("GlobalAlloc", "uint", 2, "uint", sData, "ptr") ; 2=GMEM_MOVEABLE
pGlob := DllCall("GlobalLock", "ptr", hGlob, "ptr")
DllCall("msvcrt\memcpy", "ptr", pGlob, "ptr", pData, "uint", sData, "CDecl")
DllCall("GlobalUnlock", "ptr", hGlob)
DllCall("ole32\CreateStreamOnHGlobal", "ptr", hGlob, "int", 1, "ptr*", pStream)
hGdip := DllCall("LoadLibrary", "str", "gdiplus", "Ptr")
VarSetCapacity(si, 16, 0), NumPut(1, si, "UChar")
DllCall("gdiplus\GdiplusStartup", "ptr*", gdipToken, "ptr", &si, "ptr", 0)
DllCall("gdiplus\GdipCreateBitmapFromStream", "ptr", pStream, "ptr*", pBitmap)
DllCall("gdiplus\GdipCreateHBITMAPFromBitmap", "ptr", pBitmap, "ptr*", hBitmap, "uint", 0)
SendMessage, 0x172, 0, hBitmap,, ahk_id %hPicCtrl% ; 0x172=STM_SETIMAGE, 0=IMAGE_BITMAP
GuiControl, Move, %hPicCtrl%, w240 h78
DllCall("gdiplus\GdipDisposeImage", "ptr", pBitmap)
DllCall("gdiplus\GdiplusShutdown", "ptr", gdipToken)
DllCall("FreeLibrary", "ptr", hGdip)
ObjRelease(pStream)
return
*/
User avatar
SmX1
Posts: 3
Joined: 20 Feb 2021, 18:19

Re: BMP/JPG Dans un EXE ?  Topic is solved

24 Feb 2021, 06:44

Rebonjour....

Je dois encore tester sur un pc autre que le mien mais il semblerait que ouiiiiiiiiii, j'ai réussi.

J'étais pas trop chaud pour la méthode fileinstall mais je me suis dit "et si .... dans un endroit temporaire?"

IfNotExist, %A_Temp%\avatar.jpg
fileinstall, avatar.jpg, %A_Temp%\avatar.jpg

...

Gui, Add, Picture, x1 y1 w98 h98 , %A_Temp%\avatar.jpg


et cela semble fonctionner

Merci les gars :bravo:


Test fait, presque nickel.... reconnu comme virus par avast....pffff
Je suis sur kasperky et lui ne dit rien



Par contre,Avast est pas content ...

Return to “J'ai besoin d'aide”

Who is online

Users browsing this forum: No registered users and 3 guests