; #FUNCTION# ==================================================================================================================== ; Name...........: _CreateByteArray2D ; Description ...: Erstellt die Struktur Bytearray im Zugriffs-Stil eines Array-2D ; Syntax.........: _CreateByteArray2D($sType, $iRows, $iCols) ; Parameters ....: $sType String zu speichernder Datentyp ; $iRows Anzahl Zeilen ; $iCols Anzahl Spalten ; Return values .: Bytearray-Struktur ; Author ........: BugFix ( bugfix@autoit.de ) ; Remarks .......: Zusätzlich zu den Daten werden Größe und Name des verwendeten Datentyps und die Größe der Dimensionen ; in der Struktur hinterlegt ; =============================================================================================================================== Func _CreateByteArray2D($sType, $iRows, $iCols) Local $iSize = DllStructGetSize(DllStructCreate($sType, 1)) Local $aByte = DllStructCreate('byte[' & $iSize *$iRows *$iCols & "];int size;wchar type[128];int ubound[2]") DllStructSetData($aByte, 'size', $iSize) DllStructSetData($aByte, 'type', $sType) DllStructSetData($aByte, 'ubound', $iRows, 1) DllStructSetData($aByte, 'ubound', $iCols, 2) Return $aByte EndFunc ;==>_CreateByteArray2D ; #FUNCTION# ==================================================================================================================== ; Name...........: _SetValToByteArray2D ; Description ...: Überträgt einen Wert an eine definierte Position im Bytearray ; Syntax.........: _SetValToByteArray2D($aByte, $vVal, $iRow, $iCol) ; Parameters ....: $aByte die Struktur Bytearray ; $vVal der einzutragende Wert ; $iRow Index Zeilenposition (0-basiert) ; $iCol Index Spaltenposition (0-basiert) ; Author ........: BugFix ( bugfix@autoit.de ) ; Remarks .......: Die Plausibilitätsprüfung der einzutragenden Werte bzgl. des verwendeten Datentyps ist vorher sicherzustellen ; =============================================================================================================================== Func _SetValToByteArray2D(ByRef $aByte, $vVal, $iRow, $iCol) Local $sType = DllStructGetData($aByte, 'type') Local $iSize = DllStructGetData($aByte, 'size') Local $Ub2 = _GetUBoundFromByteArray2D($aByte, 2) Local $iShiftPtr = ($iRow * $Ub2 * $iSize) + ($iCol * $iSize) Local $tmpStruct = DllStructCreate($sType, DllStructGetPtr($aByte) +$iShiftPtr) DllStructSetData($tmpStruct, 1, $vVal) EndFunc ;==>_SetValToByteArray2D ; #FUNCTION# ==================================================================================================================== ; Name...........: _GetValFromByteArray2D ; Description ...: Liest einen Wert aus einer definierten Position im Bytearray ; Syntax.........: _GetValFromByteArray2D($aByte, $iRow, $iCol) ; Parameters ....: $aByte die Struktur Bytearray ; $iRow Index Zeilenposition (0-basiert) ; $iCol Index Spaltenposition (0-basiert) ; Return values .: Der gelesene Wert ; Author ........: BugFix ( bugfix@autoit.de ) ; =============================================================================================================================== Func _GetValFromByteArray2D(ByRef $aByte, $iRow, $iCol) Local $sType = DllStructGetData($aByte, 'type') Local $iSize = DllStructGetData($aByte, 'size') Local $Ub2 = _GetUBoundFromByteArray2D($aByte, 2) Local $iShiftPtr = ($iRow * $Ub2 * $iSize) + ($iCol * $iSize) Local $tmpStruct = DllStructCreate($sType, DllStructGetPtr($aByte) +$iShiftPtr) Return DllStructGetData($tmpStruct, 1) EndFunc ;==>_GetValFromByteArray2D ; #FUNCTION# ==================================================================================================================== ; Name...........: _GetUBoundFromByteArray2D ; Description ...: Gibt die Größe der verwendeten Dimensionen zurück ; Syntax.........: _GetUBoundFromByteArray2D($aByte, $iDim = 1) ; Parameters ....: $aByte die Struktur Bytearray ; $iDim die Dimension, deren Größe erfragt wird, Standard = 1 ; Return values .: Größe der Dimension (Anzahl Elemente) ; Author ........: BugFix ( bugfix@autoit.de ) ; =============================================================================================================================== Func _GetUBoundFromByteArray2D(ByRef $aByte, $iDim = 1) If $iDim < 1 Then $iDim = 1 If $iDim > 2 Then $iDim = 2 Return DllStructGetData($aByte, 'ubound', $iDim) EndFunc ;==>_GetUBoundFromByteArray2D ; #FUNCTION# ==================================================================================================================== ; Name...........: _ByteArray2DToArray ; Description ...: Überträgt die Daten aus dem Bytearray in ein klassisches 2D-Array ; Syntax.........: _ByteArray2DToArray($aByte) ; Parameters ....: $aByte die Struktur Bytearray ; Return values .: Ein klassisches 2D-Array mit allen Werten aus der Struktur ; Author ........: BugFix ( bugfix@autoit.de ) ; =============================================================================================================================== Func _ByteArray2DToArray(ByRef $aByte) Local $iRows = _GetUBoundFromByteArray2D($aByte) Local $iCols = _GetUBoundFromByteArray2D($aByte, 2) Local $a[$iRows][$iCols] For $i = 0 To $iRows -1 For $j = 0 To $iCols -1 $a[$i][$j] = _GetValFromByteArray2D($aByte, $i, $j) Next Next Return $a EndFunc ;==>_ByteArray2DToArray