Du kannst beide Dateien in eine Datei verschmelzen und später die Mp3 wieder extrahieren:
Spoiler anzeigen
_CombineJpgMp3(@ScriptDir & "\Out.jpg", @ScriptDir & "\Test.jpg", @ScriptDir & "\Test.mp3")
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$bMp3 = _ExtractMp3(@ScriptDir & "\Out.jpg")
$hFile = FileOpen(@TempDir & "\JpgMp3.mp3", 18)
FileWrite($hFile, $bMp3)
FileClose($hFile)
SoundPlay(@TempDir & "\JpgMp3.mp3")
ShellExecuteWait(@ScriptDir & "\Out.jpg")
Func _ExtractMp3($sFile)
If Not FileExists($sFile) Then
MsgBox(16, "ERROR", $sFile & " not found")
Return
EndIf
Local $iJpgSize = _JpgGetSize($sFile)
[/autoit] [autoit][/autoit] [autoit]Local $hFile = FileOpen($sFile, 16)
Local $bMp3 = FileRead($hFile)
FileClose($hFile)
$bMp3 = BinaryMid($bMp3, $iJpgSize, BinaryLen($bMp3))
[/autoit] [autoit][/autoit] [autoit]Return $bMp3
EndFunc ;==>_ExtractMp3
Func _CombineJpgMp3($sFile, $sFile_Jpg, $sFile_Mp3)
If Not FileExists($sFile_Jpg) Then
MsgBox(16, "ERROR", $sFile_Jpg & " not found")
Return
EndIf
If Not FileExists($sFile_Mp3) Then
MsgBox(16, "ERROR", $sFile_Mp3 & " not found")
Return
EndIf
Local $hFile = FileOpen($sFile_Jpg, 16)
Local $bJpg = FileRead($hFile)
FileClose($hFile)
Local $iJpgSize = _JpgGetSize($sFile_Jpg)
If @extended Or $iJpgSize <> BinaryLen($bJpg) Then
MsgBox(16, "ERROR", "error calculating jpg size")
Return
EndIf
$hFile = FileOpen($sFile_Mp3, 16)
Local $bMp3 = FileRead($hFile)
FileClose($hFile)
$hFile = FileOpen($sFile, 18)
FileWrite($hFile, $bJpg)
FileWrite($hFile, $bMp3)
FileClose($hFile)
EndFunc ;==>_CombineJpgMp3
Func _JpgGetSize($sFile)
Local $hFile = FileOpen($sFile, 16)
Local $bJpg = FileRead($hFile)
FileClose($hFile)
Local $iLen = BinaryLen($bJpg)
Local $iSize = 0
Local $tJpg = DllStructCreate("byte Data[" & $iLen + 1 & "];")
$tJpg.Data = $bJpg
Local $iIdx = 1, $iOffset
While $iIdx < $iLen ;looking for Start Of Scan (SOS)
$iOffset = 1
If $tJpg.Data(($iIdx)) = 0xFF Then
Switch $tJpg.Data(($iIdx + 1))
Case 0x00, 0xFF ;not a marker
Case 0xD8 ;SOI
Case 0x01 ;TEM
Case 0xD0 To 0xD7 ;RST
Case 0xD9 ;EOI
$iSize = $iIdx + 2
ExitLoop
Case 0xDA ;SOS
ExitLoop
Case Else
$iOffset = ($tJpg.Data(($iIdx + 2)) * (2 ^
+ $tJpg.Data(($iIdx + 3))) + 2
EndSwitch
EndIf
$iIdx += $iOffset
WEnd
If $tJpg.Data(($iIdx)) = 0xFF And $tJpg.Data(($iIdx + 1)) = 0xDA Then
$bJpg = BinaryMid($bJpg, $iIdx, $iLen)
$iSize = $iIdx + (StringInStr($bJpg, "FFD9") - 1) / 2
EndIf
If $iSize <> $iLen Then Return SetExtended(1, $iSize)
Return $iSize
EndFunc ;==>_JpgGetSize
Speichere niemals über deine Originalbilder!!!
Das erzeugte Jpg-Bild sollte von jedem Bildbetrachter (auch mit AutoIt via GDI+) angezeigt werden können, obwohl eine Mp3 dranhängt.
Um die Mp3 abzuspielen, muss man vorher den Jpg-Teil wegschneiden.
Die Mp3 kann auch direkt (ohne im Tempordner zu speichern) vom Speicher abgespielt werden: http://www.autoitscript.com/forum/topic/12…e/#entry1004262
E