Opened 8 years ago
Closed 8 years ago
#3589 closed Bug (No Bug)
GDIPlus.au3 contains unecessary string conversions
| Reported by: | Imp | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | 3.3.14.3 | Severity: | None |
| Keywords: | Cc: |
Description
_GDIPlus_Encoders may be rewritten without using _WinAPI_WideCharsToMultibyte()
Func _GDIPlus_Encoders()
Local $iCount = _GDIPlus_EncodersGetCount()
Local $iSize = _GDIPlus_EncodersGetSize()
Local $tBuffer = DllStructCreate("byte[" & $iSize & "]")
Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageEncoders", "uint", $iCount, "uint", $iSize, "struct*", $tBuffer)
If @error Then Return SetError(@error, @extended, 0)
If $aResult[0] Then Return SetError(10, $aResult[0], 0)
Local $pBuffer = DllStructGetPtr($tBuffer)
Local $tCodec, $aInfo[$iCount + 1][14]
$aInfo[0][0] = $iCount
For $iI = 1 To $iCount
$tCodec = DllStructCreate($tagGDIPIMAGECODECINFO, $pBuffer)
$aInfo[$iI][1] = _WinAPI_StringFromGUID(DllStructGetPtr($tCodec, "CLSID"))
$aInfo[$iI][2] = _WinAPI_StringFromGUID(DllStructGetPtr($tCodec, "FormatID"))
$aInfo[$iI][3] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "CodecName")), 1 )
$aInfo[$iI][4] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "DllName")), 1 )
$aInfo[$iI][5] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "FormatDesc")), 1 )
$aInfo[$iI][6] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "FileExt")), 1 )
$aInfo[$iI][7] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "MimeType")), 1 )
$aInfo[$iI][8] = DllStructGetData($tCodec, "Flags")
$aInfo[$iI][9] = DllStructGetData($tCodec, "Version")
$aInfo[$iI][10] = DllStructGetData($tCodec, "SigCount")
$aInfo[$iI][11] = DllStructGetData($tCodec, "SigSize")
$aInfo[$iI][12] = DllStructGetData($tCodec, "SigPattern")
$aInfo[$iI][13] = DllStructGetData($tCodec, "SigMask")
$pBuffer += DllStructGetSize($tCodec)
Next
Return $aInfo
EndFunc ;==>_GDIPlus_Encoders
And _GDIPlus_Decoders():
Func _GDIPlus_Decoders()
Local $iCount = _GDIPlus_DecodersGetCount()
Local $iSize = _GDIPlus_DecodersGetSize()
Local $tBuffer = DllStructCreate("byte[" & $iSize & "]")
Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetImageDecoders", "uint", $iCount, "uint", $iSize, "struct*", $tBuffer)
If @error Then Return SetError(@error, @extended, 0)
If $aResult[0] Then Return SetError(10, $aResult[0], 0)
Local $pBuffer = DllStructGetPtr($tBuffer)
Local $tCodec, $aInfo[$iCount + 1][14]
$aInfo[0][0] = $iCount
For $iI = 1 To $iCount
$tCodec = DllStructCreate($tagGDIPIMAGECODECINFO, $pBuffer)
$aInfo[$iI][1] = _WinAPI_StringFromGUID(DllStructGetPtr($tCodec, "CLSID"))
$aInfo[$iI][2] = _WinAPI_StringFromGUID(DllStructGetPtr($tCodec, "FormatID"))
$aInfo[$iI][3] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "CodecName")), 1 )
$aInfo[$iI][4] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "DllName")), 1 )
$aInfo[$iI][5] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "FormatDesc")), 1 )
$aInfo[$iI][6] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "FileExt")), 1 )
$aInfo[$iI][7] = DllStructGetData( DllStructCreate( "wchar[128]", DllStructGetData($tCodec, "MimeType")), 1 )
$aInfo[$iI][8] = DllStructGetData($tCodec, "Flags")
$aInfo[$iI][9] = DllStructGetData($tCodec, "Version")
$aInfo[$iI][10] = DllStructGetData($tCodec, "SigCount")
$aInfo[$iI][11] = DllStructGetData($tCodec, "SigSize")
$aInfo[$iI][12] = DllStructGetData($tCodec, "SigPattern")
$aInfo[$iI][13] = DllStructGetData($tCodec, "SigMask")
$pBuffer += DllStructGetSize($tCodec)
Next
Return $aInfo
EndFunc ;==>_GDIPlus_Decoders
Also #include "WinAPIConv.au3" may be removed from top of file.
Attachments (0)
Change History (4)
follow-up: 2 comment:1 by , 8 years ago
comment:2 by , 8 years ago
Replying to Jpm:
re you sure that it is working on Asian Windows?
Why not? All of these members declared as WCHAR * in Microsoft documentation. AutoIt internally also uses WCHAR. Furthermore, conversion to multibyte and then to AutoIt strings from char[] (one by one as single chars) as is done by _WinAPI_WideCharsToMultibyte() will break the string data.
I do not have Asan Windows, but on Russian all of these string in latin alphabet.
comment:3 by , 8 years ago
Thanks,
I would have prefer to have a chinese,Japanese/Korean validation
I just wait a little bit before validation
comment:4 by , 8 years ago
| Resolution: | → No Bug |
|---|---|
| Status: | new → closed |
In fact the conversion is not done one by one but as the size is not specified the current solution is better

re you sure that it is working on Asian Windows?