Jump to content

GDI+: Getting value of string Property fails ...


 Share

Recommended Posts

sometimes!

  • Running the script below and entering a for All seems to work every time
  • Running it and choosing 1 for One returns a gibberish string
  • However with the same functions, I have seen it succeed when 1 is chosen, i.e. show the value for the test property ID 0x0103 as OLYMPUS DIGITAL CAMERA

I have also seen GetOne() succeed when a diagnostic MsgBox() is added,  and when I include my debugging functions, so the problem appears to be a memory location being overwritten, probably in a DLLStruct.. call.

I know that value OLYMPUS DIGITAL CAMERA is correct from Irfanview and from running GetAll().

All but one of the _GDIPlus functions were written by ChrisL. I have modified those that returned a DLLStruct object such that they now return an array.

Both getting one and getting  all involve calling _GDIPlus_ImageGetPropertyItemValue() which I wrote, so perhaps the problem partly lies with ChrisL's functions as modified.

Suggestions?

#include <GDIPlus.au3>
#include <Array.au3>
Opt('MustDeclareVars',1)
; #VARIABLES# ===================================================================================================================
Global $GDIP_STATUS = 0
Global $GDIP_ERROR = 0
; ===============================================================================================================================
; Property Item structure
Global Const $tagGDIPPROPERTYITEM = _
    "uint id;" & _          ; ID of this property
    "uint length;" & _      ; Length of the property value, in bytes
    "ushort type;" & _      ; Type of the value, as one of TAG_TYPE_XXX constants
    "ptr value;"            ; property value

; Image property types constants
; Ref: https://www.media.mit.edu/pia/Research/deepview/exif.html
Global Const $GDIP_PROPERTYTAGTYPEUBYTE = 1
Global Const $GDIP_PROPERTYTAGTYPEASCII = 2
Global Const $GDIP_PROPERTYTAGTYPEUSHORT = 3
Global Const $GDIP_PROPERTYTAGTYPEULONG = 4
Global Const $GDIP_PROPERTYTAGTYPEURATIONAL = 5
Global Const $GDIP_PROPERTYTAGTYPESBYTE = 6
Global Const $GDIP_PROPERTYTAGTYPEUNDEFINED = 7
Global Const $GDIP_PROPERTYTAGTYPESSHORT = 8
Global Const $GDIP_PROPERTYTAGTYPESLONG = 9
Global Const $GDIP_PROPERTYTAGTYPESRATIONAL = 10
Global Const $GDIP_PROPERTYTAGTYPESFLOAT = 11
Global Const $GDIP_PROPERTYTAGTYPEDFLOAT = 12
main()

Func main()
    _GDIPlus_Startup()

    Local $hImage = _GDIPlus_ImageLoadFromFile('H:\b\PA160005 - Copy.JPG')

    Local $sAns = InputBox('','Enter 1 or a')
    If $sAns=1 Then
        GetOne($hImage)
    ElseIf $sAns='a' Then
        GetAll($hImage)
    EndIf
    _GDIPlus_ImageDispose($hImage)
    _GDIPlus_Shutdown()
EndFunc

Func GetOne($hImage)
    Local $vecPrim = _GDIPlus_ImageGetPropertyItem($hImage,0x010e)
    Local $vecUser[3]
    $vecUser[0] = '0x'&StringRight(Hex($vecPrim[0]),4)
    $vecUser[1] = $vecPrim[2]
    Local $vecVals = _GDIPlus_ImageGetPropertyItemValue($vecPrim[1],$vecPrim[2],$vecPrim[3])
    $vecUser[2] = $vecVals[0]
    _ArrayDisplay($vecUser)
EndFunc


Func GetAll($hImage)
    Local $ar1 = _GDIPlus_ImageGetAllPropertyItems($hImage)
    Local $ar[UBound($ar1,1)][3]
    For $i = 1 To $ar1[0][0]
        $ar[$i][0] = '0x'&StringRight(Hex($ar1[$i][0]),4)
        $ar[$i][1] =$ar1[$i][2]
        $ar[$i][2] =  (_GDIPlus_ImageGetPropertyItemValue($ar1[$i][1],$ar1[$i][2],$ar1[$i][3]))[0]
    Next
    _ArrayDisplay($ar)
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_ImageGetAllPropertyItems
; Description ...: Gets all the property items (metadata) stored in an Image object
; Syntax.........: _GDIPlus_ImageGetAllPropertyItems($hImage)
; Parameters ....: $hImage - Pointer to an Image object
; Return values .: Success      - Array containing the image property items:
;                  |[0][0] - Number of property items
;                  |[1][0] - Property item 1 identifier (see remarks)
;                  |[1][1] - Property item 1 value length, in bytes
;                  |[1][2] - Property item 1 value type
;                  |[1][1] - Property item 1 value pointer
;                  |.
;                  |.
;                  |[n][0] - Property item n identifier
;                  |[n][1] - Property item n value length, in bytes
;                  |[n][2] - Property item n value type
;                  |[n][1] - Property item n value pointer
;                  Possible property value types are:
;                  |1 - The value pointer points to an array of bytes
;                  |2 - The value pointer points to a null-terminated ASCII string
;                  |3 - The value pointer points to unsigned short
;                  |4 - The value pointer points to an unsigned long
;                  |5 - The value pointer points to an array of unsigned two longs (numerator, denominator)
;                  |7 - The value pointer points to an array of bytes of any type, or is unterminated string\
;                  |8 - The value pointer points to signed short
;                  |9 - The value pointer points to a signed long
;                  |10 - The value pointer points to an array of signed two longs (numerator, denominator)
;                  |11 - The value pointer points to a float
;                  |12 - The value pointer points to a double
;                  Failure      - -1 and either:
;                  |@error and @extended are set if DllCall failed
;                  |$GDIP_STATUS contains a non zero value specifying the error code
;                  |$GDIP_ERROR:
;                  |    1 - The _GDIPlus_ImageGetPropertySize function failed, $GDIP_STATUS contains the error code
;                  |    2 - The image contains no property items metadata
;                  |    3 - The _GDIPlus_ImageGetAllPropertyItems function failed, $GDIP_STATUS contains the error code
; Author.........: Authenticity
; Modified.......: c.haslam
; Remarks .......: The property item tag identifiers are declared in GDIPConstants.au3, those that start with $GDIP_PROPERTYTAG
;                  +The value size is given in bytes, divide this by the size of the data (4 for integers, 2 for shorts, etc..)
; Related .......: _GDIPlus_ImageGetPropertySize, _GDIPlus_ImageGetPropertyItemValue, _GDIPlus_ImageGetAllPropertyItems
; Link ..........; @@MsdnLink@@ GdipGetAllPropertyItems
; Example .......; No
; ===============================================================================================================================
Func _GDIPlus_ImageGetAllPropertyItems($hImage)
    Local $iI, $iCount, $tBuffer, $pBuffer, $iBuffer, $tPropertyItem, $aSize, $aPropertyItems[1][1], $aResult

    $aSize = _GDIPlus_ImageGetPropertySize($hImage)
    If @error Then Return SetError(@error, @extended, -1)

    If $GDIP_STATUS Then
        $GDIP_ERROR = 1
        Return -1
    ElseIf $aSize[1] = 0 Then
        $GDIP_ERROR = 2
        Return -1
    EndIf

    $iBuffer = $aSize[0]
    $tBuffer = DllStructCreate("byte[" & $iBuffer & "]")
    $pBuffer = DllStructGetPtr($tBuffer)
    $iCount = $aSize[1]

    $aResult = DllCall($__g_hGDIPDll, "uint", "GdipGetAllPropertyItems", "hwnd", $hImage, "uint", $iBuffer, "uint", $iCount, "ptr", $pBuffer)
    If @error Then Return SetError(@error, @extended, -1)

    $GDIP_STATUS = $aResult[0]
    If $GDIP_STATUS Then
        $GDIP_ERROR = 3
        Return -1
    EndIf

    ReDim $aPropertyItems[$iCount + 1][4]
    $aPropertyItems[0][0] = $iCount

    For $iI = 1 To $iCount
        $tPropertyItem = DllStructCreate($tagGDIPPROPERTYITEM, $pBuffer)
        $aPropertyItems[$iI][0] = DllStructGetData($tPropertyItem, "id")
        $aPropertyItems[$iI][1] = DllStructGetData($tPropertyItem, "length")
        $aPropertyItems[$iI][2] = DllStructGetData($tPropertyItem, "type")
        $aPropertyItems[$iI][3] = DllStructGetData($tPropertyItem, "value")
        $pBuffer += DllStructGetSize($tPropertyItem)
    Next

    Return $aPropertyItems
EndFunc

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_ImageGetPropertyItemValue
; Description ...: Get property item values from fields in $tagGDIPPROPERTYITEM data
; Syntax ........: _GDIPlus_ImageGetPropertyItemValue($iLength, $iType, $pValue)
; Parameters ....: $iLength         Length of the property value, in bytes
;                  |$iType          Type of the value (a $GDIP_PROPERTYTAGTYPE* value - see GDIPConstants.au3)
;                  |$pValue         Pointer to value
; Return values .: Success      - An array
;                   |             [0] value 1
;                   |             [1] value 2 (only for properties that have numerator and denominator)
;                  Failure      - -1
; Author ........: c.haslam
; Modified ......:
; Remarks........:  If type is 7 ($GDIP_PROPERTYTAGTYPEUNDEFINED) value returned is an unsigned long.
;                   Depending on ID and originator of the image, value may actually be an unterminated string
; Related .......:  _GDIPlus_ImageGetPropertyItem,_GDIPlus_ImageGetAllPropertyItems
; Link ..........: http://www.cipa.jp/std/documents/e/DC-008-Translation-2016-E.pdf,
;                  https://www.media.mit.edu/pia/Research/deepview/exif.html
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_ImageGetPropertyItemValue($iLength, $iType, $pValue)
    Switch $iType
        Case $GDIP_PROPERTYTAGTYPEURATIONAL,$GDIP_PROPERTYTAGTYPESRATIONAL
            Local $aRet[2]
        Case Else
            Local $aRet[1]
    EndSwitch

    Switch $iType
        Case $GDIP_PROPERTYTAGTYPEUBYTE,$GDIP_PROPERTYTAGTYPESBYTE
            Local $tvalue = DllStructCreate('byte val',$pValue)
            $aRet[0] = $tvalue.val
        Case $GDIP_PROPERTYTAGTYPEASCII
            Local $tvalue = DllStructCreate('char val['&$iLength&']',$pValue)
If @error Then MsgBox(0,@ScriptLineNumber,'@error='&@error)
            $aRet[0] = DllStructGetData($tvalue,'val')
If @error Then MsgBox(0,@ScriptLineNumber,'@error='&@error)
            $aRet[0] = $tvalue.val
        Case $GDIP_PROPERTYTAGTYPEUSHORT
            Local $tvalue = DllStructCreate('ushort val',$pValue)
            $aRet[0] = $tvalue.val
        Case $GDIP_PROPERTYTAGTYPEULONG
            Local $tvalue = DllStructCreate('ulong val',$pValue)
            $aRet[0] = $tvalue.val
        Case $GDIP_PROPERTYTAGTYPEURATIONAL
            Local $tvalue = DllStructCreate('ulong val1;ulong val2',$pValue)
            $aRet[0] = $tvalue.val1
            $aRet[1] = $tvalue.val2
        Case $GDIP_PROPERTYTAGTYPESBYTE
            Local $tvalue = DllStructCreate('byte val',$pValue)
            $aRet[0] = $tvalue.val
        Case $GDIP_PROPERTYTAGTYPEUNDEFINED
            ; undefined, per specification, but may be a long but is sometimes a string
            Local $tvalue = DllStructCreate('ulong val',$pValue)
            $aRet[0] = $tvalue.val
        Case $GDIP_PROPERTYTAGTYPESSHORT
            Local $tvalue = DllStructCreate('short val',$pValue)
            $aRet[0] = $tvalue.val
        Case $GDIP_PROPERTYTAGTYPEULONG
            Local $tvalue = DllStructCreate('ulong val',$pValue)
            $aRet[0] = $tvalue.val
        Case $GDIP_PROPERTYTAGTYPESRATIONAL
            Local $tvalue = DllStructCreate('long val1;long val2',$pValue)
            $aRet[0] = $tvalue.val1
            $aRet[1] = $tvalue.val2
        Case $GDIP_PROPERTYTAGTYPESFLOAT
            Local $tvalue = DllStructCreate('float val',$pValue)
            $aRet[0] = $tvalue.val
        Case $GDIP_PROPERTYTAGTYPEDFLOAT
            Local $tvalue = DllStructCreate('double val',$pValue)
            $aRet[0] = $tvalue.val
    EndSwitch
    $tvalue = 0
    Return $aRet
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_ImageGetPropertyItem
; Description ...: Gets a specified property item (piece of metadata) from an Image object
; Syntax.........: _GDIPlus_ImageGetPropertyItem($hImage, $iPropID)
; Parameters ....: $hImage  - Pointer to an Image object
;                  $iPropID - Identifier of the property item to be retrieved
; Return values .: Success      - Array
;                   |   [0] Property ID
;                   |   [1] Property length
;                   |   [2] Property type
;                   |   [3] pointer to Property value
;                  Possible values of type are:
;                  |1 - The value pointer points to an array of bytes
;                  |2 - The value pointer points to a null-terminated ASCII string
;                  |3 - The value pointer points to unsigned short
;                  |4 - The value pointer points to an unsigned long
;                  |5 - The value pointer points to an array of unsigned two longs (numerator, denominator)
;                  |7 - The value pointer points to an array of bytes of any type, or is unterminated string\
;                  |8 - The value pointer points to signed short
;                  |9 - The value pointer points to a signed long
;                  |10 - The value pointer points to an array of signed two longs (numerator, denominator)
;                  |11 - The value pointer points to a float
;                  |12 - The value pointer points to a double
;                  Failure      - -1 and either:
;                  |@error and @extended are set if DllCall failed
;                  |$GDIP_STATUS contains a non-zero value specifying the error code
;                  |$GDIP_ERROR:
;                  |    1 - The _GDIPlus_ImageGetPropertyItemSize function failed, $GDIP_STATUS contains the error code
;                  |    2 - The specified property identifier does not exist in the image
;                  |    3 - The _GDIPlus_ImageGetPropertyItem function failed, $GDIP_STATUS contains the error code
; Author.........: Authenticity
; Modified.......: c.haslam
; Remarks .......: None
; Related .......: _GDIPlus_ImageGetPropertyIdList, _GDIPlus_ImageGetPropertyItemSize, _GDIPlus_ImageGetPropertyItemValue,
;                  $tagGDIPPROPERTYITEM
; Link ..........; @@MsdnLink@@ GdipGetPropertyItem http://www.cipa.jp/std/documents/e/DC-008-Translation-2016-E.pdf,
;                  https://www.media.mit.edu/pia/Research/deepview/exif.html
; Example .......; No
; ===============================================================================================================================
Func _GDIPlus_ImageGetPropertyItem($hImage, $iPropID)
    Local $iBuffer, $tBuffer, $pBuffer, $tPropertyItem, $aResult

    $iBuffer = _GDIPlus_ImageGetPropertyItemSize($hImage, $iPropID)
    If @error Then Return SetError(@error, @extended, -1)

    If $GDIP_STATUS Then
        $GDIP_ERROR = 1
        Return -1
    ElseIf $iBuffer = 0 Then
        $GDIP_ERROR = 2
        Return -1
    EndIf

    $tBuffer = DllStructCreate("byte[" & $iBuffer & "]")
    $pBuffer = DllStructGetPtr($tBuffer)
    $aResult = DllCall($__g_hGDIPDll, "uint", "GdipGetPropertyItem", "hwnd", $hImage, "uint", $iPropID, "uint", $iBuffer, "ptr", $pBuffer)
    If @error Then Return SetError(@error, @extended, -1)

    $GDIP_STATUS = $aResult[0]
    If $GDIP_STATUS Then
        $GDIP_ERROR = 3
        Return -1
    EndIf

    Local $tPropertyItem = DllStructCreate($tagGDIPPROPERTYITEM, $pBuffer)
    Local $aRet = [$tPropertyItem.id, $tPropertyItem.length,$tPropertyItem.type, $tPropertyItem.value]
    Return $aRet
EndFunc   ;==>_GDIPlus_ImageGetPropertyItem

; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_ImageGetPropertySize
; Description ...: Gets the total size, in bytes, and the number of all the property items stored in an Image object
; Syntax.........: _GDIPlus_ImageGetPropertySize($hImage)
; Parameters ....: $hImage  - Pointer to an Image object
; Return values .: Success      - Array containing the total size and the number of property items:
;                  |[0] - Total size, in bytes, of the property items
;                  |[1] - Number of the property items
;                  Failure      - -1 and either:
;                  |@error and @extended are set if DllCall failed
;                  |$GDIP_STATUS contains a non zero value specifying the error code
; Author.........: Authenticity
; Remarks .......: None
; Related .......: _GDIPlus_ImageGetPropertyIdList, _GDIPlus_ImageGetPropertyItem
; Link ..........; @@MsdnLink@@ GdipGetPropertyItemSize
; Example .......; No
; ===============================================================================================================================
Func _GDIPlus_ImageGetPropertySize($hImage)
    Local $aSize[2], $aResult

    $aResult = DllCall($__g_hGDIPDll, "uint", "GdipGetPropertySize", "hwnd", $hImage, "uint*", 0, "uint*", 0)
    If @error Then Return SetError(@error, @extended, -1)

    $GDIP_STATUS = $aResult[0]
    If $GDIP_STATUS Then Return -1

    $aSize[0] = $aResult[2]
    $aSize[1] = $aResult[3]
    Return $aSize
EndFunc   ;==>_GDIPlus_ImageGetPropertySize


; #FUNCTION# ====================================================================================================================
; Name...........: _GDIPlus_ImageGetPropertyItemSize
; Description ...: Gets the size, in bytes, of a specified property item of an Image object
; Syntax.........: _GDIPlus_ImageGetPropertyItemSize($hImage, $iPropID)
; Parameters ....: $hImage  - Pointer to an Image object
;                  $iPropID - Identifier of the property item to be retrieved
; Return values .: Success      - $tagGDIPPROPERTYITEM structure containing the property size, type and value pointer
;                  Failure      - -1 and either:
;                  |@error and @extended are set if DllCall failed
;                  |$GDIP_STATUS contains a non zero value specifying the error code
; Author.........: Authenticity
; Remarks .......: None
; Related .......: _GDIPlus_ImageGetPropertyIdList, _GDIPlus_ImageGetPropertyItem
; Link ..........; @@MsdnLink@@ GdipGetPropertyItemSize
; Example .......; No
; ===============================================================================================================================
Func _GDIPlus_ImageGetPropertyItemSize($hImage, $iPropID)
    Local $aResult = DllCall($__g_hGDIPDll, "uint", "GdipGetPropertyItemSize", "hwnd", $hImage, "uint", $iPropID, _
        "uint*", 0)

    If @error Then Return SetError(@error, @extended, -1)

    $GDIP_STATUS = $aResult[0]
    If $GDIP_STATUS Then Return -1
    Return $aResult[3]
EndFunc   ;==>_GDIPlus_ImageGetPropertyItemSize

 

Edited by c.haslam
corrected 0x9003 to 010e: both are string values
Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

After many hours of searching and trying, I seem to have a solution, which I found on the French AutoIt forum: for GetOne(), in which calls _GDIPlus_ImageGetPropertyItem, $tbuffer must be Static. UEZ is the author of the code there, but the difference (for me) is that the guy (orax) is retrieving a string. UEZ wrote that the reason is "because otherwise it would crash when running it as x64 exe" but I am running it from Scite on Win7 SP1 32 bit, so nothing is 84 bit about what I am doing. Any way: good news!

I look forward to someone writing a Wicki on the DLLStruct* functions. I might then understand.

I haven't figured out why GetAll(), that calls GDIPlus_ImageGetAllPropertyItems(), does not seem to need this variable to be a Static.

Edited by c.haslam
Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

You can have a look here, too (German): https://autoit.de/index.php?thread/85607-gdiplus-imagegetpropertyitems/

9 hours ago, c.haslam said:

I haven't figured out why GetAll(), that calls GDIPlus_ImageGetAllPropertyItems(), does not seem to need this variable to be a Static.

As far as I remember it was a problem running that function as x64 which cause a crash when the variable is not declared as static. Might be an Autoit bug...

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

The script on the German website runs AOK for me. There are 2 differences that I see between his code and mine:

  • His code does not make $tbuffer Static; mine (and yours) do
  • He (and you) have DllStructCreate('byte[' & $iSize & ']', $pValue) and BinaryToString(DllStructGetData($tBuffer, 1); I have char[' & $iSize & ']' and no BinaryToString call

At the risk of being offensive, I suspect a bug in AutoIt. (When I suspect a bug in AutoIt, it almost always turns out to be a bug in my code.) Perhaps only DLLCall() was in the author's mind when he designed the DLLStruct* functions.

Further, a few weeks back, before I generalized _GDIPlus_ImageGetPropertyItemValue(), I was able to do both One and All AOK. After that, adding in a diagnostic MsgBox call would cause the script to fail.  I do not remember the precise sequence of events, nor can I find the code! Perhaps I should have been more systematic in naming my file versions.

Edited by c.haslam
Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

I am looking at your  code in https://www.autoitscript.com/forum/topic/179451-solved-preserve-ascpect-ratio-_gdiplus/#comment-1287715 Post 12.

From _GDIPlus_ImageGetPropertyItem you return $tPropertyItem, a variable containing GDIPPROPERTYITEM data.

In Example(), you set $tPropItem to this.

But Example() presumably does not know that $tPropertyItem contains GDIPPROPERTYITEM data.

So does AutoIt know about $tPropItem.Value? How does it know that $tPropItem contains GDIPPROPERTYITEM data?

I had assumed that you had solved part of this problem by making $tBuffer Static: if you did not make it Static, it would be destroyed when _GDIPlus_ImageGetPropertyItem returned, then in Example(), $tPropItem could not be assured to contain GDIPPROPERTYITEM data.

How does Example know the structure of the data?

From your code, it does appear that Valik was wrong in cautioning against returning structures.

Am I making sense?

BUT in my code I am returning an array from _GDIPlus_ImageGetPropertyItem, in which none of the elements are structured data. It does not assume that the calling function knows about a structure. BUT it causes  failure until I made $tBuffer a Static. I did so as a last resort: anything to get the code working! So perhaps there is a bug in AutoIt. If there is one, it will not be easy to find!

As an aside, I wonder whether AutoIt releases memory used by structures when execution of a function ends.

Decades back, I took German 100. At that time, I could visit West Germany and be understood. I still remember a bit of German.

Edited by c.haslam
added a few paragraphs
Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

Link to comment
Share on other sites

Having got the property functions working in my test script, I copied them to my 6000-line project, which had been working well.

Reading a few or all properties worked OK as shown by calling _ArrayDIsplay(). Then calling it again a few lines later either showed 0 for the values of string properties or AutoIt crashed, depending on which line the call was.

Two snippets:

$Dsk_ghImage = _GDIPlus_ImageLoadFromFile($filspc)
    Local $idsVec = [0x9003,0x9004] ; ; DateTimeOriginal, DateTimeDigitzed
    Local $propsAr[UBound($idsVec)][5]
    Local $vecPrim,$valsVec
    For $i = 0 To UBound($idsVec)-1
        Local $vecPrim = _GDIPlus_ImageGetPropertyItemEx($Dsk_ghImage,$idsVec[$i])
        $propsAr[$i][0] = $vecPrim[0]   ; id
        $propsAr[$i][1] = $vecPrim[1]       ; length
        $propsAr[$i][2] = $vecPrim[2]       ; type
        $propsAr[$i][3] = $vecPrim[3]       ; val1
        Local $valsVec = _GDIPlus_ImageGetPropertyItemValue($vecPrim[1],$vecPrim[2],$vecPrim[3])
        $propsAr[$i][3] = $valsVec[0]       ; val1
        If $vecPrim[2]=5 Or $vecPrim[2]=10 Then     ; $GDIP_PROPERTYTAGTYPEURATIONAL,$GDIP_PROPERTYTAGTYPESRATIONAL
            $propsAr[$i][4] = $valsVec[1]       ; val2
        EndIf
    Next

and

Case $btnOK
_ArrayDisplay($propsAr,@ScriptLineNumber)   ; OK here
                    ; These 2 lines un-double-lock the file
                    _GDIPlus_GraphicsDispose($hGfxClone)
_ArrayDisplay($propsAr,@ScriptLineNumber)   ; OK here
                    _GDIPlus_ImageDispose($Dsk_ghImage)
_ArrayDisplay($propsAr,@ScriptLineNumber)   ;  crashes atfer showing GUI  title, before showing data

 

Ideas?

Later

I have compared the version that did not crash (and worked well) [call it v. W] and the version that crashed [call it v. C].

I then carefully commented out all of the Properties code. v. C still crashed.

I then removed the commented-out code from v. C to make comparison easier. v. C still crashed.

I used TextPad to compare v. W and v. W. There was one difference:

Local Const $kPrId=0,$kPrLength=1,$kPrType=2,$kPrVal1=3,$kPrVal2=4

None of these constants were used. I commented out this line.

I ran v. C again. It did not crash.

I do use global constants often, but this was the first time I had used local constants.

I realize that I had been running with v. 3.3.14.2, which was not my intention.

I un-commented this line.

I pressed Alt_F5 to run with v. 3.3.15.0.

v. C did not crash.

So it appears that there was a bug 3.3.14.2 (but the Change log for 3.3.15.0 does not list it as fixed.)

I ran Toggle AU3 beta. It said "Now using RELEASE 3.3.14.2". So, to me, pressing F5 should have run the beta.

I then ran Toggle AU3 beta again. It said "Now using BETA 3.3.15.0". So I should be back to F5 running the beta. But looking at the Console, I see that F5 runs the Release, not the Beta. Strange!

Am I missing something?

It is likely that my crashing problem was entirely due to Local Const, not Properties functions.

Edited by c.haslam
Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

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...