Sign in to follow this  
Followers 0
UEZ

Help to understand C++ code

5 posts in this topic

#1 ·  Posted (edited)

I'm trying to understand following code which I want to convert to Autoit:

RedEyeCorrection

VOID Example_RedEyeSetParameters(HDC hdc)
{
   Graphics graphics(hdc);
   Image myImage(L"RedEyePhoto.jpg");

   REAL srcWidth = (REAL)myImage.GetWidth();
   REAL srcHeight = (REAL)myImage.GetHeight();
   RectF srcRect(0.0f, 0.0f, srcWidth, srcHeight);
   Matrix myMatrix(1.0f, 0.0f, 0.0f, 1.0f, 300.0f, 20.0f);

   RECT redAreas[2] = {40, 10, 55, 30, 110, 20, 125, 40};

   RedEyeCorrectionParams myRedEyeCorParams;
   myRedEyeCorParams.numberOfAreas = 2;
   myRedEyeCorParams.areas = redAreas;

   RedEyeCorrection myRedEyeCor;
   myRedEyeCor.SetParameters(&myRedEyeCorParams);

   // Draw the image with no change.
   graphics.DrawImage(&myImage, 20.0, 20.0, srcWidth, srcHeight);

   // Draw the image with the red eye correction.
   graphics.DrawImage(&myImage, &srcRect, &myMatrix, &myRedEyeCor, NULL, UnitPixel);
}

I made something like this here

Global $tRECT1 = DllStructCreate("long left;long top;long right;long buttom")
DllStructSetData($tRECT1, "left", 55)
DllStructSetData($tRECT1, "top", 69)
DllStructSetData($tRECT1, "right", 68)
DllStructSetData($tRECT1, "buttom", 81)
Global $pRECT1 = DllStructGetPtr($tRECT1)

Global $tRECT2 = DllStructCreate("long left;long top;long right;long buttom")
DllStructSetData($tRECT2, "left", 159)
DllStructSetData($tRECT2, "top", 68)
DllStructSetData($tRECT2, "right", 172)
DllStructSetData($tRECT2, "buttom", 81)
Global $pRECT2 = DllStructGetPtr($tRECT2)

Global Const $tagREDEYECORRECTIONPARAMS = "uint numberOfAreas;int areas[2]"
Global $tRedEye = DllStructCreate($tagREDEYECORRECTIONPARAMS)
Global Const $pRedEye = DllStructGetPtr($tRedEye)
DllStructSetData($tRedEye, "numberOfAreas", 2)
DllStructSetData($tRedEye, "areas", $tRECT1, 1)
DllStructSetData($tRedEye, "areas", $tRECT2, 2)
$hEffect = _GDIPlus_EffectCreate($GDIP_REDEYECORRECTIONEFFECT)
ConsoleWrite(_GDIPlus_EffectsSetParameters($hEffect, $pRedEye) & " / " & @error & @LF)

but it is not working - return code 8, error code 2.

I'm an absolute C++ noob and I hope somebody can help here. ;)

Br,

UEZ

Edited by UEZ

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites



UEZ,

Your RECT structures must be contiguous in memory, so you have to create them in one DLLStruct, something like:

$tRECTs = DLLStructCreate("long[" & $nNumRects*4 "];")

Also the RedEyeCorrectionParams structure should be (the 2nd field gets a ptr to $tRECTS):

$tagREDEYECORRECTIONPARAMS = "uint numberOfAreas;ptr areas;"

Finally, I'm not sure about how you implement the 'SetParameters' call. It's defined like this in the Windows SDK:

GdipSetEffectParameters(CGpEffect *effect, const VOID *params, const UINT size);

..and called like this (although I'm not sure why sizeof(RECT) is used as its separate from the structure):

GdipSetEffectParameters(&Effect, &Params, sizeof(RedEyeCorrectionParams) + (sizeof(RECT) * nNumAreas) )

You might want to look at 'gdipluseffects.h" header in the Windows SDK, if you have it.

1 person likes this

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks Ascend4nt,

here whole code:

;http://msdn.microsoft.com/en-us/library/windows/desktop/ms534056(v=vs.85).aspx
#include <GDIplus.au3>
#include <Memory.au3>

Global Const $GDIP_BLUREFFECT = "{633C80A4-1843-482b-9EF2-BE2834C5FDD4}"
Global Const $GDIP_BRIGHTNESSCONTRASTEFFECT = "{D3A1DBE1-8EC4-4c17-9F4C-EA97AD1C343D}"
Global Const $GDIP_COLORBALANCEEFFECT = "{537E597D-251E-48da-9664-29CA496B70F8}"
Global Const $GDIP_COLORCURVEEFFECT = "{DD6A0022-58E4-4a67-9D9B-D48EB881A53D}"
Global Const $GDIP_COLORLUTEFFECT = "{A7CE72A9-0F7F-40d7-B3CC-D0C02D5C3212}"
Global Const $GDIP_COLORMATRIXEFFECT = "{718F2615-7933-40e3-A511-5F68FE14DD74}"
Global Const $GDIP_HUESATURATIONLIGHTNESSEFFECT = "{8B2DD6C3-EB07-4d87-A5F0-7108E26A9C5F}"
Global Const $GDIP_LEVELSEFFECT = "{99C354EC-2A31-4f3a-8C34-17A803B33A25}"
Global Const $GDIP_REDEYECORRECTIONEFFECT = "{74D29D05-69A4-4266-9549-3CC52836B632}"
Global Const $GDIP_TINTEFFECT = "{1077AF00-2848-4441-9489-44AD4C2D7A2C}"
Global Const $GDIP_SHARPENEFFECT = "{63CBF3EE-C526-402c-8F71-62C540BF5142}"

_GDIPlus11_Startup()
If @error Then Exit MsgBox(0x40010, "Error", "GDI+ Effect Collection can run on operating systems Vista or newer only!")


Global $hBitmap = _GDIPlus_BMPFromMemory(_RedEye())
Global $iW = _GDIPlus_ImageGetWidth($hBitmap)
Global $iH = _GDIPlus_ImageGetHeight($hBitmap)
Global $hGUI = GUICreate("GDI+ v1.1 Effect Collection by UEZ 2013", $iW * 2, $iH, -1 , 100)
GUISetState()

Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, $iW, 0, $iW, $iH)

Global $hEffect

Global $tRECTF = DllStructCreate($tagGDIPRECTF)
DllStructSetData($tRECTF, "X", 0)
DllStructSetData($tRECTF, "Y", 0)
DllStructSetData($tRECTF, "Width", $iW)
DllStructSetData($tRECTF, "Height", $iH)
Global $pRECTF = DllStructGetPtr($tRECTF)

;Color LUT
Global Const $tagCOLORLUTPARAMS = "byte ColorChannelLUTB[256];byte ColorChannelLUTG[256];byte ColorChannelLUTR[256];byte ColorChannelLUTA[256]"
Global $tColorLUT = DllStructCreate($tagCOLORLUTPARAMS)
For $i = 192  To 256
    DllStructSetData($tColorLUT, "ColorChannelLUTR", 0xA0, $i)
    DllStructSetData($tColorLUT, "ColorChannelLUTG", 0xB0, $i)
    DllStructSetData($tColorLUT, "ColorChannelLUTB", 0xC0, $i)
Next
$hEffect = _GDIPlus_ColorLUT($tColorLUT)
ConsoleWrite("Color LUT" & @CRLF)
_GDIPlus_DrawImageFX($hGraphics, $hBitmap, $pRECTF, $hEffect)
_GDIPlus_EffectDispose($hEffect)
Sleep(3000)

;Blur
Global Const $tagBLURPARAMS = "float radius;bool expandEdge" ;0-255; False/True
Global $tBlur = DllStructCreate($tagBLURPARAMS)
$hEffect = _GDIPlus_Blur($tBlur, 10)
ConsoleWrite("Blur" & @CRLF)
_GDIPlus_DrawImageFX($hGraphics, $hBitmap, $pRECTF, $hEffect)
_GDIPlus_EffectDispose($hEffect)
Sleep(3000)

;Brightness Contrast
Global Const $tagBRIGHTNESSCONTRASTPARAMS = "int brightnessLevel;int contrastLevel" ;-255-255; -100-100
Global $tBrightnessContrast = DllStructCreate($tagBRIGHTNESSCONTRASTPARAMS)
$hEffect = _GDIPlus_BrightnessContrast($tBrightnessContrast, -60, 90)
ConsoleWrite("Brightness Contrast" & @CRLF)
_GDIPlus_DrawImageFX($hGraphics, $hBitmap, $pRECTF, $hEffect)
_GDIPlus_EffectDispose($hEffect)
Sleep(3000)

;Color Balance
Global Const $tagCOLORBALANCEPARAMS = "int cyanRed;int magentaGreen;int yellowBlue" ;-100-100; -100-100; -100-100
Global $tColorBalance = DllStructCreate($tagCOLORBALANCEPARAMS)
$hEffect = _GDIPlus_ColorBalance($tColorBalance, 60, -50, 20)
ConsoleWrite("Color Balance" & @CRLF)
_GDIPlus_DrawImageFX($hGraphics, $hBitmap, $pRECTF, $hEffect)
_GDIPlus_EffectDispose($hEffect)
Sleep(3000)

;Color Curve
Global Enum $iAdjustExposure = 0, $iAdjustDensity, $iAdjustContrast,    $iAdjustHighlight, $iAdjustShadow, _ ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms534098(v=vs.85).aspx
                            $iAdjustMidtone, $iAdjustWhiteSaturation, $iAdjustBlackSaturation
Global Enum $iCurveChannelAll = 0, $iCurveChannelRed, $iCurveChannelGreen, $iCurveChannelBlue ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms534100(v=vs.85).aspx
Global Const $tagCOLORCURVEEFFECTPARAMS = "int type;int channel;int value"
Global $tColorCurve = DllStructCreate($tagCOLORCURVEEFFECTPARAMS)
$hEffect = _GDIPlus_ColorCurve($tColorCurve, $iAdjustHighlight, $iCurveChannelAll, 90)
ConsoleWrite("Color Curve" & @CRLF)
_GDIPlus_DrawImageFX($hGraphics, $hBitmap, $pRECTF, $hEffect)
_GDIPlus_EffectDispose($hEffect)
Sleep(3000)

;Color Matrix
Global Const $tagGDIPCOLORMATRIXPARAMS = "float m[25];"
Global $tColorMatrix = DllStructCreate($tagGDIPCOLORMATRIXPARAMS)
Global $fRed = 0.66, $fGreen = 0.5, $fBlue = 0.5, $fAlpha = 1
$hEffect = _GDIPlus_ColorMatrix($tColorMatrix, $fRed, $fGreen, $fBlue, $fAlpha)
ConsoleWrite("Color Matrix" & @CRLF)
_GDIPlus_DrawImageFX($hGraphics, $hBitmap, $pRECTF, $hEffect)
_GDIPlus_EffectDispose($hEffect)
Sleep(3000)

;Hue Saturation Lightness
Global Const $tagHUESATURATIONLIGHTNESSPARAMS = "int hueLevel;int saturationLevel;int lightnessLevel" ;-180-180; -100-100; -100-100
Global $tHueSaturationLightness = DllStructCreate($tagHUESATURATIONLIGHTNESSPARAMS)
$hEffect = _GDIPlus_HueSaturationLightness($tHueSaturationLightness, 90, -50, 20)
ConsoleWrite("Hue Saturation Lightness" & @CRLF)
_GDIPlus_DrawImageFX($hGraphics, $hBitmap, $pRECTF, $hEffect)
_GDIPlus_EffectDispose($hEffect)
Sleep(3000)

;Levels
Global Const $tagLEVELSPARAMS = "int highlight;int midtone;int shadow" ;0-100; -100-100; 0-100
Global $tLevels = DllStructCreate($tagLEVELSPARAMS)
$hEffect = _GDIPlus_Levels($tLevels, 60, -50, 20)
ConsoleWrite("Levels" & @CRLF)
_GDIPlus_DrawImageFX($hGraphics, $hBitmap, $pRECTF, $hEffect)
_GDIPlus_EffectDispose($hEffect)
Sleep(3000)

;Sharpen
Global Const $tagSHARPENPARAMS = "float radius;float amount" ;0-255; 0-100
Global $tSharpen = DllStructCreate($tagSHARPENPARAMS)
$hEffect = _GDIPlus_Sharpen($tSharpen, 60, 90)
ConsoleWrite("Sharpen" & @CRLF)
_GDIPlus_DrawImageFX($hGraphics, $hBitmap, $pRECTF, $hEffect)
_GDIPlus_EffectDispose($hEffect)
Sleep(3000)

;Tint
Global Const $tagTINTPARAMS = "int hue;int amount" ;-180-180; -100-100
Global $tTint = DllStructCreate($tagTINTPARAMS)
$hEffect = _GDIPlus_Tint($tTint, 60, 40)
ConsoleWrite("Tint" & @CRLF)
_GDIPlus_DrawImageFX($hGraphics, $hBitmap, $pRECTF, $hEffect)
_GDIPlus_EffectDispose($hEffect)
Sleep(3000)

;Red Eye -> http://msdn.microsoft.com/en-us/library/windows/desktop/ms534928(v=vs.85).aspx
Global $nNumRects = 2
Global $tRECTs = DLLStructCreate("long[" & $nNumRects * 4  & "];")
DllStructSetData($tRECTs, 1, 50, 1)
DllStructSetData($tRECTs, 1, 64, 2)
DllStructSetData($tRECTs, 1, 50 + 22, 3)
DllStructSetData($tRECTs, 1, 64 + 18, 4)
DllStructSetData($tRECTs, 1, 155, 5)
DllStructSetData($tRECTs, 1, 64, 6)
DllStructSetData($tRECTs, 1, 155 + 21, 7)
DllStructSetData($tRECTs, 1, 64 + 18, 8)
Global Const $pRECTs = DllStructGetPtr($tRECTs)
Global Const $tagREDEYECORRECTIONPARAMS = "uint numberOfAreas;ptr areas;"
Global $tRedEye = DllStructCreate($tagREDEYECORRECTIONPARAMS)
Global Const $pRedEye = DllStructGetPtr($tRedEye)
DllStructSetData($tRedEye, "numberOfAreas", $nNumRects)
DllStructSetData($tRedEye, "areas", $pRECTs)

$hEffect = _GDIPlus_EffectCreate($GDIP_REDEYECORRECTIONEFFECT)
;~ ConsoleWrite(_GDIPlus_EffectsSetParametersRE($hEffect, $pRedEye, DllStructGetSize($tRedEye) + ($nNumRects * 4*4)) & " / " & @error & @LF)
ConsoleWrite("Red Eye" & @CRLF)
_GDIPlus_EffectsSetParameters($hEffect, $pRedEye, (DllStructGetSize($tRECTs) + DllStructGetSize($tRedEye)) / DllStructGetSize($tRedEye))
_GDIPlus_DrawImageFX($hGraphics, $hBitmap, $pRECTF, $hEffect)

;~ $hBitmap_Effect = _GDIPlus_BitmapCreateApplyEffect($hBitmap, $hEffect)
;~ _GDIPlus_GraphicsDrawImage($hGraphics, $hBitmap_Effect, 0, 0)

$tBlur = 0
$tTint = 0
$tColorCurve = 0
$tSharpen = 0
$tColorMatrix = 0
$tBrightnessContrast = 0
$tLevels = 0
$tColorBalance = 0
$tColorColorChannelLUT = 0
$tRedEye = 0
$tRECTF1 = 0
$tRECTF2 = 0
$tRECTF = 0

Sleep(4000)
MsgBox(0, "", "Done", 15)

Do
Until GUIGetMsg() = -3


_GDIPlus_BitmapDispose($hBitmap)
;~ _GDIPlus_BitmapDispose($hBitmap_Effect)
_GDIPlus_GraphicsDispose($hGraphics)

_GDIPlus_Shutdown()

Exit

Func _GDIPlus_Blur($tBlur, $fRadius, $bExpandEdge = False)
    If Not IsDllStruct($tBlur) Then Return SetError(1, @error, 0)
    DllStructSetData($tBlur, "radius", $fRadius)
    DllStructSetData($tBlur, "expandEdge", $bExpandEdge)
    Local $hEffect = _GDIPlus_EffectCreate($GDIP_BLUREFFECT)
    If @error Then Return SetError(2, @error, 0)
    _GDIPlus_EffectsSetParameters($hEffect, DllStructGetPtr($tBlur))
    If @error Then Return SetError(3, @error, 0)
    Return $hEffect
EndFunc

Func _GDIPlus_BrightnessContrast($tBrightnessContrast, $iBrightnessLevel, $iContrastLevel)
    If Not IsDllStruct($tBlur) Then Return SetError(1, @error, 0)
    DllStructSetData($tBrightnessContrast, "brightnessLevel", $iBrightnessLevel)
    DllStructSetData($tBrightnessContrast, "contrastLevel", $iContrastLevel)
    Local $hEffect = _GDIPlus_EffectCreate($GDIP_BRIGHTNESSCONTRASTEFFECT)
    If @error Then Return SetError(2, @error, 0)
    _GDIPlus_EffectsSetParameters($hEffect, DllStructGetPtr($tBrightnessContrast))
    If @error Then Return SetError(3, @error, 0)
    Return $hEffect
EndFunc

Func _GDIPlus_ColorBalance($tColorBalance, $iCyanRed, $iMagentaGreen, $iYellowBlue)
    If Not IsDllStruct($tBlur) Then Return SetError(1, @error, 0)
    DllStructSetData($tColorBalance, "cyanRed", $iCyanRed)
    DllStructSetData($tColorBalance, "magentaGreen", $iMagentaGreen)
    DllStructSetData($tColorBalance, "yellowBlue", $iYellowBlue)
    Local $hEffect = _GDIPlus_EffectCreate($GDIP_COLORBALANCEEFFECT)
    If @error Then Return SetError(2, @error, 0)
    _GDIPlus_EffectsSetParameters($hEffect, DllStructGetPtr($tColorBalance))
    If @error Then Return SetError(3, @error, 0)
    Return $hEffect
EndFunc

Func _GDIPlus_ColorCurve($tColorCurve, $iType, $iChannel, $iValue)
    If Not IsDllStruct($tBlur) Then Return SetError(1, @error, 0)
    DllStructSetData($tColorCurve, "type", $iType)
    DllStructSetData($tColorCurve, "channel", $iChannel)
    DllStructSetData($tColorCurve, "value", $iValue)
    Local $hEffect = _GDIPlus_EffectCreate($GDIP_COLORCURVEEFFECT)
    If @error Then Return SetError(2, @error, 0)
    _GDIPlus_EffectsSetParameters($hEffect, DllStructGetPtr($tColorCurve))
    If @error Then Return SetError(3, @error, 0)
    Return $hEffect
EndFunc

Func _GDIPlus_ColorLUT($tColorLUT)
    If Not IsDllStruct($tColorLUT) Then Return SetError(1, @error, 0)
    Local $hEffect = _GDIPlus_EffectCreate($GDIP_COLORLUTEFFECT)
    If @error Then Return SetError(2, @error, 0)
    _GDIPlus_EffectsSetParameters($hEffect, DllStructGetPtr($tColorLUT))
    If @error Then Return SetError(3, @error, 0)
    Return $hEffect
EndFunc

Func _GDIPlus_ColorMatrix($tColorMatrix, $fRed, $fGreen, $fBlue, $fAlpha)
    If Not IsDllStruct($tBlur) Then Return SetError(1, @error, 0)
    DllStructSetData($tColorMatrix, "m", $fRed, 1)
    DllStructSetData($tColorMatrix, "m", $fGreen, 7)
    DllStructSetData($tColorMatrix, "m", $fBlue, 13)
    DllStructSetData($tColorMatrix, "m", $fAlpha, 19)
    DllStructSetData($tColorMatrix, "m", 1, 25) ;the element in the fifth row and fifth column of a 5×5 homogeneous matrix must be 1, and all of the other elements in the fifth column must be 0
    Local $hEffect = _GDIPlus_EffectCreate($GDIP_COLORMATRIXEFFECT)
    If @error Then Return SetError(2, @error, 0)
    _GDIPlus_EffectsSetParameters($hEffect, DllStructGetPtr($tColorMatrix))
    If @error Then Return SetError(3, @error, 0)
    Return $hEffect
EndFunc

Func _GDIPlus_HueSaturationLightness($tHueSaturationLightness, $iHueLevel, $iSaturationLevel, $iLightnessLevel)
    If Not IsDllStruct($tBlur) Then Return SetError(1, @error, 0)
    DllStructSetData($tHueSaturationLightness, "hueLevel", $iHueLevel)
    DllStructSetData($tHueSaturationLightness, "saturationLevel", $iSaturationLevel)
    DllStructSetData($tHueSaturationLightness, "lightnessLevel", $iLightnessLevel)
    Local $hEffect = _GDIPlus_EffectCreate($GDIP_HUESATURATIONLIGHTNESSEFFECT)
    If @error Then Return SetError(2, @error, 0)
    _GDIPlus_EffectsSetParameters($hEffect, DllStructGetPtr($tHueSaturationLightness))
    If @error Then Return SetError(3, @error, 0)
    Return $hEffect
EndFunc

Func _GDIPlus_Levels($tLevels, $iHighlight, $iMidtone, $iShadow)
    If Not IsDllStruct($tBlur) Then Return SetError(1, @error, 0)
    DllStructSetData($tLevels, "highlight", 60)
    DllStructSetData($tLevels, "midtone", -50)
    DllStructSetData($tLevels, "shadow", 20)
    Local $hEffect = _GDIPlus_EffectCreate($GDIP_LEVELSEFFECT)
    If @error Then Return SetError(2, @error, 0)
    _GDIPlus_EffectsSetParameters($hEffect, DllStructGetPtr($tLevels))
    If @error Then Return SetError(3, @error, 0)
    Return $hEffect
EndFunc

Func _GDIPlus_Sharpen($tSharpen, $fRadius, $fAmount)
    If Not IsDllStruct($tBlur) Then Return SetError(1, @error, 0)
    DllStructSetData($tSharpen, "radius", $fRadius)
    DllStructSetData($tSharpen, "amount", $fAmount)
    Local $hEffect = _GDIPlus_EffectCreate($GDIP_SHARPENEFFECT)
    If @error Then Return SetError(2, @error, 0)
    _GDIPlus_EffectsSetParameters($hEffect, DllStructGetPtr($tSharpen))
    If @error Then Return SetError(3, @error, 0)
    Return $hEffect
EndFunc

Func _GDIPlus_Tint($tTint, $iHue, $iAmount)
    If Not IsDllStruct($tBlur) Then Return SetError(1, @error, 0)
    DllStructSetData($tTint, "hue", $iHue)
    DllStructSetData($tTint, "amount", $iAmount)
    Local $hEffect = _GDIPlus_EffectCreate($GDIP_TINTEFFECT)
    If @error Then Return SetError(2, @error, 0)
    _GDIPlus_EffectsSetParameters($hEffect, DllStructGetPtr($tTint))
    If @error Then Return SetError(3, @error, 0)
    Return $hEffect
EndFunc

Func _GDIPlus_EffectCreate($sEffectGUID, $pEffect = 0)
    Local $iI, $tGUID, $pGUID, $tElem, $aElem[4], $aResult
    $tGUID = _WinAPI_GUIDFromString($sEffectGUID)
    $pGUID = DllStructGetPtr($tGUID)
    $tElem = DllStructCreate("uint[4]", $pGUID)
    For $iI = 1 To 4
        $aElem[$iI - 1] = DllStructGetData($tElem, 1, $iI)
    Next
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateEffect", "uint", $aElem[0], "uint", $aElem[1], "uint", $aElem[2], "uint", $aElem[3], "uint*", $pEffect)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[5])
EndFunc   ;==>_GDIPlus_EffectCreate

Func _GDIPlus_EffectsSetParameters($hEffectObject, $pEffectParameters, $iSizeAdj = 1)
    Local $aSize = DllCall($ghGDIPDll, "uint", "GdipGetEffectParameterSize", "handle", $hEffectObject, "uint*", 0)
    Local $iSize = $aSize[2] * $iSizeAdj
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetEffectParameters", "handle", $hEffectObject, "ptr", $pEffectParameters, "uint", $iSize)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[3])
EndFunc   ;==>_GDIPlus_EffectsSetParameters

Func _GDIPlus_BitmapCreateApplyEffect($hBitmap, $hEffect, $pROI = 0, $pOutRect = 0, $hBmpOutput = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipBitmapCreateApplyEffect", _
            "ptr*", $hBitmap, _
            "int", 1, _
            "handle", $hEffect, _
            "ptr", $pROI, _
            "ptr", $pOutRect, _
            "int*", $hBmpOutput, _
            "int", 0, "ptr*", 0, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[6])
EndFunc   ;==>_GDIPlus_BitmapCreateApplyEffect

Func _GDIPlus_EffectDispose($hEffect)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipDeleteEffect", "handle", $hEffect)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc   ;==>_GDIPlus_EffectDispose

Func _GDIPlus_BitmapApplyEffect($hBitmap, $hEffect, $pROI = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipBitmapApplyEffect", "handle", $hBitmap, "handle", $hEffect, "ptr", $pROI, "int", 0, "ptr*", 0, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc   ;==>_GDIPlus_BitmapApplyEffect

Func _GDIPlus_DrawImageFX($hGraphics, $hBitmap, $pRECTF, $hEffect, $hMatrix = 0, $ImgAttributes = 0, $iUnit = 2)
    $aResult = DllCall($ghGDIPDll, "uint", "GdipDrawImageFX", "handle", $hGraphics, _
            "handle", $hBitmap, _
            "ptr", $pRECTF, _
            "handle", $hMatrix, _
            "handle", $hEffect, _
            "ptr", $ImgAttributes, _
            "uint", $iUnit)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc   ;==>_GDIPlus_DrawImageFX

Func _GDIPlus11_Startup() ;code by Authenticity - modified by UEZ
    Local $pInput, $tInput, $pToken, $tToken, $aResult, $os

    $giGDIPRef += 1
    If $giGDIPRef > 1 Then Return True

    Switch @OSVersion
        Case "WIN_VISTA", "WIN_2008"
            $ghGDIPDll = DllOpen(@WindowsDir & "\winsxs\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.6000.16386_none_8df21b8362744ace\gdiplus.dll")
        Case "WIN_2008R2", "WIN_7", "WIN_8"
            $ghGDIPDll = DllOpen(@SystemDir & "\gdiplus.dll")
        Case Else
            Return SetError(1)
    EndSwitch
;~     _WinAPI_Check("_GDIPlus_Startup (GDIPlus.dll not found)", @error, False)

    $tInput = DllStructCreate($tagGDIPSTARTUPINPUT)
    $pInput = DllStructGetPtr($tInput)
    $tToken = DllStructCreate("int Data")
    $pToken = DllStructGetPtr($tToken)
    DllStructSetData($tInput, "Version", 1)
    $aResult = DllCall($ghGDIPDll, "int", "GdiplusStartup", "ptr", $pToken, "ptr", $pInput, "ptr", 0)
    If @error Then Return SetError(@error, @extended, False)
    $giGDIPToken = DllStructGetData($tToken, "Data")
    Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus11_Startup


#region Example Image
;======================================================================================
; Function Name:        _GDIPlus_BMPFromMemory
; Description:              Loads an image which is saved as a binary string and converts it to a bitmap or hbitmap
;
; Parameters:               $bImage:    the binary string which contains any valid image which is supported by GDI+
; Optional:                     $hHBITMAP:  if false a bitmap will be created, if true a hbitmap will be created
;
; Remark:                       hbitmap format is used generally for GUI internal images, $bitmap is more a GDI+ image format
;                                       Don't forget _GDIPlus_Startup() and _GDIPlus_Shutdown()
;
; Requirement(s):       GDIPlus.au3, Memory.au3 and _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
; Return Value(s):      Success: handle to bitmap (GDI+ bitmap format) or hbitmap (WinAPI bitmap format),
;                                       Error: 0
; Error codes:              1: $bImage is not a binary string
;                                       2: unable to create stream on HGlobal
;                                       3: unable to create bitmap from stream
;
; Author(s):                    UEZ
; Additional Code:      thanks to progandy for the MemGlobalAlloc and tVARIANT lines and
;                                       Yashied for _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
; Version:                      v0.98 Build 2012-08-29 Beta
;=======================================================================================
Func _GDIPlus_BMPFromMemory($bImage, $hHBITMAP = False)
    If Not IsBinary($bImage) Then Return SetError(1, 0, 0)
    Local $aResult
    Local Const $memBitmap = Binary($bImage) ;load image  saved in variable (memory) and convert it to binary
    Local Const $len = BinaryLen($memBitmap) ;get length of image
    Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory  ($GMEM_MOVEABLE = 0x0002)
    Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer
    Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct
    DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data
    _MemGlobalUnlock($hData) ;decrements the lock count  associated with a memory object that was allocated with GMEM_MOVEABLE
    $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0) ;Creates a stream object that uses an HGLOBAL memory handle to store the stream contents
    If @error Then Return SetError(2, 0, 0)
    Local Const $hStream = $aResult[3]
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface
    If @error Then Return SetError(3, 0, 0)
    Local Const $hBitmap = $aResult[2]
    Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
    DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _
                                           "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak
    $tMem = 0
    $tVARIANT = 0
    If $hHBITMAP Then
        Local Const $hHBmp = _WinAPI_BitmapCreateDIBFromBitmap($hBitmap)
        _GDIPlus_BitmapDispose($hBitmap)
        Return $hHBmp
    EndIf
    Return $hBitmap
EndFunc   ;==>_GDIPlus_BMPFromMemory

Func _WinAPI_BitmapCreateDIBFromBitmap($hBitmap) ;create 32-bit bitmap v5 (alpha channel supported)
    Local $tBIHDR, $aRet, $tData, $pBits, $hResult = 0
    $aRet = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0)
    If (@error) Or ($aRet[0]) Then Return 0
    $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aRet[2], $aRet[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB)
    $pBits = DllStructGetData($tData, 'Scan0')
    If Not $pBits Then Return 0
    $tBIHDR = DllStructCreate(  'dword bV5Size;long bV5Width;long bV5Height;word bV5Planes;word bV5BitCount;dword bV5Compression;' & _ ;http://msdn.microsoft.com/en-us/library/windows/desktop/dd183381(v=vs.85).aspx
                                                                'dword bV5SizeImage;long bV5XPelsPerMeter;long bV5YPelsPerMeter;dword bV5ClrUsed;dword bV5ClrImportant;'  & _
                                                                'dword bV5RedMask;dword bV5GreenMask;dword bV5BlueMask;dword bV5AlphaMask;dword bV5CSType;' & _
                                                                'int bV5Endpoints[3];dword bV5GammaRed;dword bV5GammaGreen;dword bV5GammaBlue;dword bV5Intent;' & _
                                                                'dword bV5ProfileData;dword bV5ProfileSize;dword bV5Reserved')
    DllStructSetData($tBIHDR, 'bV5Size', DllStructGetSize($tBIHDR))
    DllStructSetData($tBIHDR, 'bV5Width', $aRet[2])
    DllStructSetData($tBIHDR, 'bV5Height', $aRet[3])
    DllStructSetData($tBIHDR, 'bV5Planes', 1)
    DllStructSetData($tBIHDR, 'bV5BitCount', 32)
    DllStructSetData($tBIHDR, 'bV5Compression', 0) ; $BI_BITFIELDS = 3, $BI_RGB = 0, $BI_RLE8 = 1, $BI_RLE4 = 2, $RGBA = 0x41424752
    DllStructSetData($tBIHDR, 'bV5SizeImage', $aRet[3] * DllStructGetData($tData, 'Stride'))
    DllStructSetData($tBIHDR, 'bV5AlphaMask', 0xFF000000)
    DllStructSetData($tBIHDR, 'bV5RedMask', 0x00FF0000)
    DllStructSetData($tBIHDR, 'bV5GreenMask', 0x0000FF00)
    DllStructSetData($tBIHDR, 'bV5BlueMask', 0x000000FF)
    DllStructSetData($tBIHDR, 'bV5CSType', 2) ; LCS_WINDOWS_COLOR_SPACE = 2
    DllStructSetData($tBIHDR, 'bV5Intent', 4) ; $LCS_GM_IMA
    $hResult = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBIHDR), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0)
    If (Not @error) And ($hResult[0]) Then
        DllCall('gdi32.dll', 'dword', 'SetBitmapBits', 'ptr', $hResult[0], 'dword', $aRet[2] * $aRet[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0'))
        $hResult = $hResult[0]
    Else
        $hResult = 0
    EndIf
    _GDIPlus_BitmapUnlockBits($hBitmap, $tData)
    $tData = 0
    $tBIHDR = 0
    Return $hResult
EndFunc   ;==>_WinAPI_BitmapCreateDIBFromBitmap

;Code below was generated by: 'File to Base64 String' Code Generator v1.11 Build 2012-10-13

Func _RedEye($bSaveBinary = False)
    Local $RedEye
    $RedEye &= '/9j/4AAQSkZJRgABAQEBLAEsAAD//gBERmlsZSBzb3VyY2U6IGh0dHA6Ly9jb21tb25zLndpa2ltZWRpYS5vcmcvd2lraS9GaWxlOkJvbGRSZWRFeWUuSlBH/9sAQwAGBAUGBQQGBgUGBwcGCAoQCgoJCQoUDg8MEBcUGBgXFBYWGh0lHxobIxwWFiAsICMmJykqKRkfLTAtKDAlKCko/9sAQwEHBwcKCAoTCgoTKBoWGigoKCgoKCgoKC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Cs1gLMQIzjmlk14z61VpEDPes66cabW7kBIJ42AqWkMrdcAxEdqTTQxo5Sc/WkDBkyQcmmkU3uCKCtWOLCZ3iltGthHDKiRgmltpPWglyylwEKAIjkUHKXL6eEL1sah3AODStVMtTVMha62xr+aKuVz5e1RsztnNPaPGCEWf5agAB60rVToInp7ZXK06ozBqPt0+V9DbdlKT8okbUy2MSdJ2zRtFXtuYHFOVNixyFIJJqhLqh1zsPuaTTc+wroknGIoPYZxXIkwd6DDunyaeIyaC39hn3PmgASPpTRZoA+sgKKonseKqOfkv4C3EJ0TnVkg44n61rXJWavLhX4p0mVEmSRNYZZarfHHoT1R0uWzobSFypQPuMx+la4M+X/vIrQwpBnVM7/tRVYHlooxEzUV0Y2G1uoTvioaymVuoxuZ2E0mko5gmRJwaDM2VTjahmKQ4AN5o2VVOrzMZqbVYqyed6AiZJM8cUz2taQCRjNJGVGttpKIj9KuMrX3hxxinobWBseHPP8Aeke+wbqYXMDNRemsvSl19LbjaVTKsAxTt0vDC5S2LgrO0UqlJK4pbC8Lx6VUqUVq82aez+gziSTj2oPYR48Zg9jTOBFqkiSByZoOhn9iRsMY7U2VoF0AvQSkgEA/Srxc2d6DXylpWYASdMgRtxV2ucht2g+lThVEqxisNb7dmONs6ZD4P6i89069bfWta0veIVkzMiumyS9OG2+W6e4UsGIkgCOPKDtUVthTK0mTxmKixvKaW6sEZxUVriZMrIUJpVriPaOUig9mFucJ9aSbRBUYEUk7cnaeaBKiFSfQUj2mkSByfWmW1rf2EU5E0e2sBkECrnplfbhdEHFGzkSS7qSMR2o9wa0oeTmDzU2HMgq0hwDUNjik2xysfJKisgxAxUn9Jp3PtS2m1NKiFAb0wm4cA0ylDPKg01TsC6rWJ43FNfoK5kCQNJmnCtDkkygGABNNjnfsvcUUztG3rNaRz53ZX1G40NPOpEeQx6YoyvTKTt5v1jrvULbqLrNq8W2kQNMcwKMMJZtr/Uyx6j//2Q=='
    Local $bString = Binary(_Base64Decode($RedEye))
    If $bSaveBinary Then
        Local $hFile = FileOpen(@ScriptDir & "\220px-BoldRedEye.JPG", 18)
        FileWrite($hFile, $bString)
        FileClose($hFile)
    EndIf
    Return  $bString
EndFunc   ;==>_RedEye

Func _Base64Decode($sB64String)
    Local $struct = DllStructCreate("int")
    Local $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $sB64String, "int", 0, "int", 1, "ptr", 0, "ptr", DllStructGetPtr($struct, 1), "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(1, 0, "")
    Local $a = DllStructCreate("byte[" & DllStructGetData($struct, 1) & "]")
    $a_Call = DllCall("Crypt32.dll", "int", "CryptStringToBinary", "str", $sB64String, "int", 0, "int", 1, "ptr", DllStructGetPtr($a), "ptr", DllStructGetPtr($struct, 1), "ptr", 0, "ptr", 0)
    If @error Or Not $a_Call[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($a, 1)
EndFunc   ;==>_Base64Decode
#endregion

All other FX are working except teh red eye one!

It is still not working when I did it the way you described. Hmmm....

Br,

UEZ

Edited by UEZ

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

I added an alternative function call to 'GdipSetEffectParameters' which accepts a size, and also fixed the code where you set the "areas" structure member, and it seems to return okay. However, I don't actually see anything displayed in the GUI when I select a picture, so I'm not sure what that's about.

Here's the code adjustments:

Func _GDIPlus_EffectsSetParametersRE($hEffectObject, $pEffectParameters, $nSize)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetEffectParameters", "handle", $hEffectObject, "ptr", $pEffectParameters, "uint", $nSize)
    If @error Then Return SetError(@error, @extended, 0)
    Return SetError($aResult[0], 0, $aResult[3])
EndFunc   ;==>_GDIPlus_EffectsSetParameters

Global $nNumRects = 2
Global $tRECTs = DLLStructCreate("long[" & $nNumRects * 4  & "];")
DllStructSetData($tRECTs, 1, 55, 1)
DllStructSetData($tRECTs, 1, 69, 2)
DllStructSetData($tRECTs, 1, 68, 3)
DllStructSetData($tRECTs, 1, 81, 4)
DllStructSetData($tRECTs, 1, 159, 5)
DllStructSetData($tRECTs, 1, 68, 6)
DllStructSetData($tRECTs, 1, 172, 7)
DllStructSetData($tRECTs, 1, 81, 8)
Global Const $tagREDEYECORRECTIONPARAMS = "uint numberOfAreas;ptr areas;"
Global $tRedEye = DllStructCreate($tagREDEYECORRECTIONPARAMS)
Global Const $pRedEye = DllStructGetPtr($tRedEye)
DllStructSetData($tRedEye, "numberOfAreas", $nNumRects)
DllStructSetData($tRedEye, "areas", DllStructGetPtr($tRECTs))
$hEffect = _GDIPlus_EffectCreate($GDIP_REDEYECORRECTIONEFFECT)
;ConsoleWrite(_GDIPlus_EffectsSetParameters($hEffect, $pRedEye) & " / " & @error & @LF)
ConsoleWrite(_GDIPlus_EffectsSetParametersRE($hEffect, $pRedEye, DllStructGetSize($tRedEye) + ($nNumRects * 4*4)) & " / " & @error & @LF)
1 person likes this

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Ascend4nt,

thank you very much for your help! Now it seems to work whereas I've to check the coordinates of the red eyes.

Indeed, I forgot the line _GDIPlus_DrawImageFX($hGraphics, $hBitmap, $pRECTF, $hEffect) to display the affected image.

I updated the code from post#3.

Br,

UEZ

Edited by UEZ

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • czardas
      By czardas
      Haven't had much time to code recently. However the following thread inspired me.
      The debate about linear, parallel and binary search methods was rather interesting and, in an attempt to be diplomatic, I decided to combine @jchd's suggestion with @LarsJ's binary search example. I decided that the binary search algorithm required modification to make it more linear. As usual, 'if you invent something, it probably already exists and if it already exists, it exists for a reason'. My first attempt was not all that good. The code worked but was really a mess. I blame peer pressure (to post an example of a parallel search method).  I will delete that old code in due course.
      With a little memory jogging and a glance at the help file, the solution turned out to be quite easy: I just needed a better understanding of Euler. Further modification will be needed to work with more complicated unicode strings. The output could be returned as an array or a delimitered string. I'm not so interested in those details. I'm just going to post the algorithm for now and anyone, who wants to, can modify it to suit their needs. Both arrays must contain at least 1 element.
      Local $aFoo = [0,1,2,3,4,5,6,7,9,10,11,12,13,14,15,16,19,20,23,24,26,30,35,39,40,41] Local $aBar = [0,1,5,6,7,8,9,10,11,12,13,14,17,18,19,21,24,25,26,27,34,35,38,40] ParallelExponetialSearch($aFoo, $aBar) ; Compares two lists - returning positive matches. Each input array must be unique (individually) and in alphabetical order. Func ParallelExponetialSearch($aFoo, $aBar) Local $sFind, _ $iMin_F = -1, $iMax_F = UBound($aFoo) -1, $Lo_F = $iMin_F, $Hi_F, _ $iMin_B = -1, $iMax_B = UBound($aBar) -1, $Lo_B = $iMin_B, $Hi_B While $iMin_F < $iMax_F And $iMin_B < $iMax_B ; Toggle Arrays - Which array has most untested elements? This is the one we want to search next, ; so we can bypass more comparisons because (in theory) mismatches have a greater chance of being skipped. If $iMax_F - $iMin_F >= $iMax_B - $iMin_B Then ; $aFoo has more (or an equal number of) untested elements $Hi_F = $iMax_F $iMin_B += 1 $sFind = $aBar[$iMin_B] While $Lo_F < $Hi_F ; search $aFoo For $i = 0 To Floor(Log($Hi_F - $Lo_F) / Log(2)) $Lo_F = $iMin_F + 2^$i If $aFoo[$Lo_F] = $sFind Then $iMin_F = $Lo_F ; each match should be added to the output [perhaps an array] ConsoleWrite($sFind & " found at $aFoo[" & $Lo_F & "] = $aBar[" & $iMin_B & "]" & @LF) ExitLoop 2 ElseIf $aFoo[$Lo_F] > $sFind Then $Hi_F = $Lo_F -1 $iMin_F += Floor(2^($i -1)) $Lo_F = $iMin_F ContinueLoop 2 EndIf Next $iMin_F = $Lo_F ; minimum increment is one WEnd Else ; $aBar has more untested elements $Hi_B = $iMax_B $iMin_F += 1 $sFind = $aFoo[$iMin_F] While $Lo_B < $Hi_B ; search $aBar For $i = 0 To Floor(Log($Hi_B - $Lo_B) / Log(2)) $Lo_B = $iMin_B + 2^$i If $aBar[$Lo_B] = $sFind Then $iMin_B = $Lo_B ; each match should be added to the output [perhaps an array] ConsoleWrite($sFind & " found at $aFoo[" & $iMin_F & "] = $aBar[" & $Lo_B & "]" & @LF) ExitLoop 2 ElseIf $aBar[$Lo_B] > $sFind Then $Hi_B = $Lo_B -1 $iMin_B += Floor(2^($i -1)) $Lo_B = $iMin_B ContinueLoop 2 EndIf Next $iMin_B = $Lo_B ; minimum increment is one WEnd EndIf WEnd EndFunc ;==> ParallelExponetialSearch I hope this will be useful to someone. I believe it deserved a thread of its own!
    • RC86
      By RC86
      Afternoon!
      I have a requirement to return both a string and an array from a function so as a result I put them both into an array and returned that.  I can access them in their entirety after returning them but then I can't seem to access the array elements after this.  Should I be able to or is there a prettier way?
      #include <Array.au3> ;Memory info returned as a string and an array $memoryInfo = _getMemoryInfo() msgbox(0,"Memory Info",$memoryInfo[0]) _ArrayDisplay($memoryInfo[1],"Memory as an Array") Local $newArray[7] $memoryInfo[1] = $newArray msgbox(0,"Test element",$newArray[0]) _ArrayDisplay($newArray) Func _getMemoryInfo() Local $newArray[7] Local $array = MemGetStats() $newArray[0] = $array[0] ;% of memory in use $newArray[1] = Round($array[1]/1024 * 0.001,2) ;Total physical RAM $newArray[2] = Round($array[2]/1024 * 0.001,2) ;Availaible physical RAM $newArray[3] = Round($array[3]/1024 * 0.001,2) ;Total pagefile $newArray[4] = Round($array[4]/1024 * 0.001,2) ;Available pagefile $newArray[5] = Round($array[5]/1024 * 0.001,2) ;Total virtual $newArray[6] = Round($array[6]/1024 * 0.001,2) ;Available virtual $memoryUsage = $newArray[1] - $newarray[2] $pagefileUsage = $newArray[3] - $newarray[4] ;Output/Return Local $returnArray[2] $returnArray[0] = "Memory: " & $memoryUsage & " GB/" & $newArray[1] & " GB " & @CRLF & "Pagefile: " & $pagefileUsage & " GB/" & $newArray[3] & " GB " $returnArray[1] = $newArray return $returnArray EndFunc A bit messy but hopefully it's understandable what I'm trying to achieve.
      Thanks!
    • Jibberish
      By Jibberish
      I am having difficulties getting updated results from GUICtrlCreateInput. I wrote a small script to demonstrate what I am trying to do.
      This script reads a text file into an array and displays the Name and Number from the text file.
      The user can check a name and change the number, and the results are displayed in _ArrayDisplay.
      Only the Checked names are displayed in their original position. This is necessary for future
      plumbing.
      The problem with this script is the original number is returned, not the changed number. I cannot
      figure out how to get the updated number to be displayed.
      ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; This script reads a text file into an array and displays the Name and Number from the text file. ; The user can check a name and change the number, and the results are displayed in _ArrayDisplay. ; Only the Checked names are displayed in their original position. This is necessary for future ; plumbing. ; ; The problem with this script is the original number is returned, not the changed number. I cannot ; figure out how to get the updated number to be displayed. ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #include-once #include <MsgBoxConstants.au3> #include <array.au3> #include <Date.au3> #include <WinAPIFiles.au3> #include <AutoItConstants.au3> #include <Misc.au3> #include <File.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> Local $iMax = 6 ;Default number of Videos - 1 for the array counter Dim $aTextFile[$iMax][2] ; [start with 5 entries][Name, Number] Don't get confused! [Row][Column] Local $i = 0 Local $iLeft = 30 Local $iTop = 30 Local $sName Local $sNumber Local $aArray Local $iMaxCol = 5 Local $iRow = 0 Local $iCol = 0 Local $aNumberCount[$iMaxCol][2] $aArray1 = ReadFile() $aNamesNumbers = DisplayNames($aArray1) _ArrayDisplay($aNamesNumbers) ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; ReadFile() places the contents of the NameNumber.txt file in an array ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func ReadFile() Local $sFileData = @ScriptDir & "\NameNumber.txt" Local $iStrReturn = 0 Local $aArrayFile Local $aTextFile[$iMaxCol][2] Local $aName Local $sCheckBox1 Const $iL = 10 ; Count from Left for GUI so all buttons line up Local $sFill Local $iA = 0, $iN = 0 ; Put the Names into an Array _FileReadToArray($sFileData, $aArrayFile) For $iA = 0 To $aArrayFile[0] ; Step through the array looking for Names If StringInStr($aArrayFile[$iA], "Name:") Then $aName = StringSplit($aArrayFile[$iA],":") $sFill = $aName[2] If UBound($aTextFile) <= $iRow Then ; Resize the array when $iRow is equal to the element count in the array to prevent subscript error ReDim $aTextFile[UBound($aTextFile) + 1][$iMaxCol] EndIf $aTextFile[$iRow][$iCol] = $sFill $iRow += 1 EndIf Next $iCol = 1 $iRow = 0 $sFill = "" For $iA = 1 To $aArrayFile[0] ; Step through the array looking for Numbers If StringInStr($aArrayFile[$iA], "Number:") Then $aName = StringSplit($aArrayFile[$iA],":") $sFill = $aName[2] If UBound($aTextFile) <= $iRow Then ; Resize the array when $iRow is equal to the element count in the array to prevent subscript error ReDim $aTextFile[UBound($aTextFile) + 1][$iMaxCol] EndIf $aTextFile[$iRow][$iCol] = $sFill $iRow += 1 EndIf Next Return $aTextFile EndFunc ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Display the Name and Number ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Func DisplayNames($aArray1) Local $aName[$iMax] Local $aNumbers[$iMax] $iMMCount = UBound($aArray1) $iMMCount -=1 Local $iWidth = 300 Local $iLength = 300;$iMMCount * 30 GUISetFont(12) $hGUI = GUICreate("Edit / Update Number Test", $iWidth, $iLength, -1, -1) GUICtrlCreateLabel(" Name Number",1,5) ;$iTop += 30 ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Display Name with a Checkbox. Only Checked Names should be saved. ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For $i = 0 to $iMMCount Step 1 $sNameText = $aArray1[$i][0] $iNameLength = StringLen($sNameText) $aName[$i] = GUICtrlCreateCheckbox($sNameText,$iLeft, $iTop) $iTop += 30 Next ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Display the number from the text file below each name. Allow the user to change the number and display the ; new number. ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $iLeft = 60 GUIStartGroup() $iTop = 28 For $i = 0 to $iMMCount Step 1 $sNumberText = $aArray1[$i][1] $aNumberCount[$i][1] = $sNumberText $aNumberCount[$i][0] = GUICtrlCreateInput($sNumberText,$iLeft, $iTop, 50,18, $GUI_DOCKAUTO) GUICtrlSetPos($aNumberCount[$i][0],200) $iTop += 30 Next ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; Read the checked names and (possibly updated) number ; ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $iMMCount = UBound($aNumberCount) $iMMNewCount = $iMMCount - 1 Local $aGUICheckbox[$iMMCount] Local $aCheckedNameNumber[$iMMCount][2] $iLeft = 30 Local $idCloseGUI = GUICtrlCreateButton("Close",$iLeft, $iTop) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idCloseGUI For $i = 0 To $iMMNewCount Step 1 Switch GUICtrlRead($aName[$i]) Case $GUI_CHECKED $aCheckedNameNumber[$i][0] = $aArray1[$i][0] Case $GUI_UNCHECKED EndSwitch Switch GUICtrlRead($aNumberCount[$i][0]) Case $aCheckedNameNumber[$i][1] = GUICtrlRead($aNumberCount[$i][1]) EndSwitch Next ExitLoop EndSwitch WEnd For $i = 0 to $iMMNewCount step 1 GUICtrlRead($aNumberCount[$i][0]) If $aCheckedNameNumber[$i][0] <> "" Then $aCheckedNameNumber[$i][1] = $aNumberCount[$i][1] EndIf Next GUIDelete($hGUI) Return $aCheckedNameNumber EndFunc This is the text file I am reading. If you want to try this out put the NameNumber.txt file in your script directory. It's attached to the post.
      * This is a dummy file with a Name and Number * The only purpose of this file is to read the updated Number. Name:Taggart Number:916 Name:Mongo Number:90 Name:Hedley Lamarr Number:22 Name:Bart Number:9999 Name:The Waco Kid Number:2244 If I change the number, the original number is displayed at the end, not the updated/modified number. I need the modified number to be displayed.
      Thanks in advance for any assistance!
      Jibberish
      NameNumber.txt
    • Jibberish
      By Jibberish
      I am working on a Video Player Test Script. I am reading a text file into a 3d array to be displayed in a GUI.
      Array Content:
      [x][0]FileName.mp4
      [x][1]UsageCount -> Up to a 4 digit number
      [x][2]EnableUsageCount (True/False)
      In the GUI the user can check the filename box, edit the number of usages and check EnableUsageCount to turn on the UsageCount control using the UsageCount number for the maximum number of plays.
      To make this easier to deal with I have removed the EnableUsageCount section, and am just concentrating on getting a method to put the edited (or unchanged) UsageCount in the array. Currently nothing is read into the array, due to my using the wrong method in the Case statement.
      Here are code snippets of what I am trying to do:
      ; Snippets from script ; I read the text file at the bottom and put the .mp4 filenames in $aManifest[x][0] and UsageCount in $aManifest[x][1] ; Then I create a GUI to display the .mp4 filenames with checkboxes and the UsageCount to the right. UsageCount is editable by the user. ; If the filename is checked, I want to read the filename into $aCheckedVideos[x][0] and the updated UsageCount in $aCheckedVideos[x][1] ; The GUICtrlRead($aVideoName[$i]) with Case $GUI_CHECKED & UNCHECKED works for the checkboxes ; This section puts the filenames in the GUI with a checkbox For $i = 0 to $iMMCount Step 1 $sMP4Text = $aManifest[$i][0] $iMP4Length = StringLen($sMP4Text) $aVideoName[$i] = GUICtrlCreateCheckbox($sMP4Text,$iLeft, $iTop) $iTop += 30 Next ; This section reads numbers from the Manifest array, and I want to be able to change the number and have them saved. ; So the Case $GUI_CHECKED & UNCHECKED won't work here, and I can't figure out what I should be doing here. For $i = 0 to $iMMCount Step 1 $sUsageText = $aManifest[$i][1] $aUsageCount[$i] = GUICtrlCreateInput($sUsageText,$iLeft, $iTop, 50,18, $GUI_DOCKAUTO) GUICtrlSetPos($aUsageCount[$i],200) $iTop += 30 Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idCloseGUI For $i = 0 To $iMMNewCount Step 1 Switch GUICtrlRead($aVideoName[$i]) Case $GUI_CHECKED $aCheckedVideos[$i][0] = $aManifest[$i][0] ; If checked, I put the results into a two D array Case $GUI_UNCHECKED ; where Video Name is $aCheckedVideos[x][0] EndSwitch Switch GUICtrlRead($aUsageCounter[$i]) Case $GUI_CHECKED $aCheckedVideos[$i][1] = $aUsageCount[$i] ;I want to put the text (numbers) in $aCheckedVideos[x][1] Case $GUI_UNCHECKED ;but what is returned is blank, probably due to EndSwitch ; $GUI_CHECKED being the wrong thing. Next ExitLoop EndSwitch WEnd ;The txt file I'm reading has the following: ;~ /** Title #1: Big Buck Bunny 1080p **/ ;~ "Name": "Big Buck Bunny", ;~ "URI": "..\\MediaFiles\\bbb_1080_60s.mp4", ;~ "UsageCount": 9999, ;~ "URI": "..\\MediaFiles\\bbb_1080_60s_enc1.mp4", ;~ "UsageCount": 45, ;~ "URI": "..\\MediaFiles\\bbb_1080_60s_enc1.mp4", ;~ "UsageCount": 2, ;~ /** Title #2: Tears of Steel 4K **/ ;~ "Name": "Tears of Steel 4K", ;~ "URI": "..\\MediaFiles\\tos_4K_60s_HEVC.mp4", ;~ "UsageCount": 9876, ;~ "URI": "..\\MediaFiles\\tos_4K_60s_HEVC_enc2.mp4", ;~ "UsageCount": 0, ;~ "URI": "..\\MediaFiles\\tos_4K_60s_HEVC_enc2.mp4", ;~ "UsageCount": 5, I am certain that the section
                          Switch GUICtrlRead($aUsageCounter[$i])
                              Case $GUI_CHECKED
                                  $aCheckedVideos[$i][1] = $aUsageCount[$i]    ;I want to put the text (numbers) in $aCheckedVideos[x][1]
                              Case $GUI_UNCHECKED                                ;but what is returned is blank, probably due to
                          EndSwitch                                            ; $GUI_CHECKED being the wrong thing.

      is wrong, and this is what I am looking for help with. Instead of $GUI_CHECKED what should I be looking for?
      The worst part of this is I had this working late last night, and then lost my changes and cannot for the life of me remember how I had this working.
      Help is truly appreciated!
      Jibberish
       
    • algiuxas
      By algiuxas
      Hello everybody, so I might found a bug in _ArraySearch:
       
      #include <Array.au3> Local $abc[2] = ["b", "b"] $h = "+---------------------------------+" & @CRLF ConsoleWrite($h) For $i = 0 To 1 $abc[0] = 0 out() $abc[0] = 1 out() $abc[0] = -1 out() $abc[0] = "Abc" out() $abc[1] = "Hello" Next Func txt() Return "$abc = [" & $abc[0] & ", " & $abc[1] & "]" & @CRLF & _ "> _ArraySearch($abc,""Hello"") = " EndFunc ;==>txt Func shouldoutput($ans) Return "_ArraySearch Should return: " & ($ans ? 1 : -1) EndFunc ;==>shouldoutput Func out() ConsoleWrite("> " & txt() & _ArraySearch($abc, "Hello") & @CRLF & "> " & shouldoutput($abc[1] == "Hello") & @CRLF & $h) EndFunc ;==>out Exit Sorry for this messy script