#Region ;**** Directives created by AutoIt3Wrapper_GUI ****#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Resources\icon.ico #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Description=Image Effects #AutoIt3Wrapper_Res_Fileversion=1.0.0.1 #AutoIt3Wrapper_Res_LegalCopyright=GreenCan #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #Tidy_Parameters=/gd 1 /gds 1 /nsdp #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include-once #include #include #include #include #include #include Opt('MustDeclareVars', 1) Global $sFileName = FileOpenDialog("Select an image", "", "Images (*.bmp;*.png;*.jpg;*.gif;*.tif)") If @error Then Exit _ImageEffects($sFileName) Exit Func _ImageEffects($sFileName) Local $hGUI, $hFileMenu, $hSaveBtn, $hSaveBtn2, $hCloseBtn, $hCloseBtn2, $msg, $iGUIWidth, $iGUIHeight Local $hBitmap_original, $hBitmap_Scaled, $hClone, $aClone, $iWidth, $iHeight, $iOriginalWidth, $iOriginalHeight, $iScale, $iError Local $iBright = 0, $iContrast = 0, $iHue = 0, $iSaturate = 0, $iLightness = 0, $iBlur = 0 Local $iCBRed = 0, $iCBGreen = 0, $iCBBlue = 0, $iHighlight = 100, $iMidtone = 0, $iShadow = 0 Local $fRadius = 10, $fAmount = 50, $iTintHue = 0, $iTintAmount = 0 Local $h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn Local $aEffectsHistory[1][4] = [[0, "", "", ""]] _GDIPlus_Startup() ; initialize GDI+ $hBitmap_original = _GDIPlus_ImageLoadFromFile($sFileName) ;Create an image object based on a file $iWidth = _GDIPlus_ImageGetWidth($hBitmap_original) $iOriginalWidth = $iWidth $iOriginalHeight = _GDIPlus_ImageGetHeight($hBitmap_original) $iWidth = _Lowest($iWidth, @DesktopWidth - 50) $iHeight = $iOriginalHeight * $iWidth / $iOriginalWidth If $iHeight > @DesktopHeight - 350 Then $iWidth = $iWidth / $iHeight * (@DesktopHeight - 350) $iHeight = @DesktopHeight - 350 EndIf $iScale = ($iWidth/$iOriginalWidth) If $iScale < 1 Then $hBitmap_Scaled = _GDIPlus_ImageScale($hBitmap_original, $iScale, $iScale) ; not showing in GUI Else $hBitmap_Scaled = $hBitmap_original EndIf $hClone = _GDIPlus_BitmapCloneArea($hBitmap_Scaled, 0, 0, $iWidth, $iHeight) $iGUIWidth = _Highest($iWidth, 1000) $iGUIHeight = $iHeight + 215 $hGUI = GUICreate("Image effects " & StringRegExpReplace($sFileName, ".*\\", "") & " [" & $iOriginalWidth & "x" & $iOriginalHeight & "]", $iGUIWidth, $iGUIHeight) ;create a test GUI $hFileMenu = GUICtrlCreateMenu("&File") $hSaveBtn = GUICtrlCreateMenuItem("&Save Image", $hFileMenu) $hCloseBtn = GUICtrlCreateMenuItem("&Close Window", $hFileMenu) $h_BC_Btn = GUICtrlCreateButton("Brightness/Contrast", 10, $iHeight + 5, 200, 30) $h_HSL_Btn = GUICtrlCreateButton("Hue/Saturation/Lightness", 10, $iHeight + 40, 200, 30) $h_Blur_Btn = GUICtrlCreateButton("Blur", 10, $iHeight + 75, 200, 30) $h_ColBal_Btn = GUICtrlCreateButton("Color Balance (RGB)", 10, $iHeight + 110, 200, 30) $hLevels_Btn = GUICtrlCreateButton("Levels (HMS)", 10, $iHeight + 145, 200, 30) $h_Sharpen_Btn = GUICtrlCreateButton("Sharpen", 220, $iHeight + 5, 200, 30) $h_Tint_Btn = GUICtrlCreateButton("Tint", 220, $iHeight + 40, 200, 30) $h_Undo_Btn = GUICtrlCreateButton("Undo", 220, $iHeight + 110, 200, 30) $hSaveBtn2 = GUICtrlCreateButton("Save", 220, $iHeight + 145, 120, 30) $hCloseBtn2 = GUICtrlCreateButton("Exit", 345, $iHeight + 145, 75, 30) GUISetState(@SW_SHOW) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ;create a graphics object from a window handle _GDIPlus_GraphicsDrawImageRect($hGraphics, $hClone, ($iGUIWidth - $iWidth)/2, 0, $iWidth, $iHeight) ; now use slider to control brightness While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE, $hCloseBtn, $hCloseBtn2 ;cleanup GDI+ resources _GDIPlus_ImageDispose($hClone) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_ImageDispose($hBitmap_Scaled) _GDIPlus_BitmapDispose($hBitmap_original) _GDIPlus_Shutdown() GUIDelete($hGUI) Return SetError(1, 0, "") Case $hSaveBtn, $hSaveBtn2 If $aEffectsHistory[0][0] = 0 Then ContinueLoop MsgBox(48, "Info", "No effects have been applied, not need to save this image") _SaveClone($sFileName, $hClone) ; this line will save the image on screen (eventually resized id scale applied), for test purpose only _SaveLossless($sFileName, $hBitmap_original, $aEffectsHistory, $iScale) ; save the original sized bitmap with all applied effects If @error Then $iError = @error MsgBox(48, "Error", "Could not save image, error: " & $iError) EndIf Case $h_BC_Btn _DisableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) $aClone = BitmapApplyEffect($hClone, $hGraphics, $iWidth, $iHeight, $iGUIWidth, $iGUIHeight, "BC", "Brightness", $iBright, 255, -255, "Contrast", $iContrast, 100, -100) If Not @error Then $hClone = $aClone[0] $iBright = $aClone[1] $iContrast = $aClone[2] ReDim $aEffectsHistory[$aEffectsHistory[0][0] + 2][4] $aEffectsHistory[0][0] += 1 $aEffectsHistory[$aEffectsHistory[0][0]][0] = "BC" $aEffectsHistory[$aEffectsHistory[0][0]][1] = $iBright $aEffectsHistory[$aEffectsHistory[0][0]][2] = $iContrast ; reset values because applied destructive filter $iBright = 0 $iContrast = 0 EndIf _EnableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) Case $h_HSL_Btn _DisableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) $aClone = BitmapApplyEffect($hClone, $hGraphics, $iWidth, $iHeight, $iGUIWidth, $iGUIHeight, "HSL", "Hue", $iHue, 100, -100, "Saturation", $iSaturate, 100, -100, "Lightness", $iLightness, 100, -100) If Not @error Then $hClone = $aClone[0] $iHue = $aClone[1] $iSaturate = $aClone[2] $iLightness = $aClone[3] ReDim $aEffectsHistory[$aEffectsHistory[0][0] + 2][4] $aEffectsHistory[0][0] += 1 $aEffectsHistory[$aEffectsHistory[0][0]][0] = "HSL" $aEffectsHistory[$aEffectsHistory[0][0]][1] = $iHue $aEffectsHistory[$aEffectsHistory[0][0]][2] = $iSaturate $aEffectsHistory[$aEffectsHistory[0][0]][3] = $iLightness ; reset values because applied destructive filter $iHue = 0 $iSaturate = 0 $iLightness = 0 EndIf _EnableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) Case $h_Blur_Btn _DisableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) #cs Note: if the image is scaled, the Radius of the Blur will be limited according to the scale. A maximum blur Radius of 255, gves a different result depending on the size of the image, as we want the same result on screen as on the larger final result, we need to limit the Radius accordingly #ce $aClone = BitmapApplyEffect($hClone, $hGraphics, $iWidth, $iHeight, $iGUIWidth, $iGUIHeight, "Blur", "Blur", $iBlur, 255 * $iScale, 0) If Not @error Then $hClone = $aClone[0] $iBlur = $aClone[1] ReDim $aEffectsHistory[$aEffectsHistory[0][0] + 2][4] $aEffectsHistory[0][0] += 1 $aEffectsHistory[$aEffectsHistory[0][0]][0] = "Blur" $aEffectsHistory[$aEffectsHistory[0][0]][1] = $iBlur ; reset value because applied destructive filter $iBlur = 0 EndIf _EnableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) Case $h_ColBal_Btn _DisableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) $aClone = BitmapApplyEffect($hClone, $hGraphics, $iWidth, $iHeight, $iGUIWidth, $iGUIHeight, "ColBal", "Color Balance - Red", $iCBRed, 100, -100, "Green", $iCBGreen, 100, -100, "Blue", $iCBBlue, 100, -100) If Not @error Then $hClone = $aClone[0] $iCBRed = $aClone[1] $iCBGreen = $aClone[2] $iCBBlue = $aClone[3] ReDim $aEffectsHistory[$aEffectsHistory[0][0] + 2][4] $aEffectsHistory[0][0] += 1 $aEffectsHistory[$aEffectsHistory[0][0]][0] = "ColBal" $aEffectsHistory[$aEffectsHistory[0][0]][1] = $iCBRed $aEffectsHistory[$aEffectsHistory[0][0]][2] = $iCBGreen $aEffectsHistory[$aEffectsHistory[0][0]][3] = $iCBBlue ; reset values because applied destructive filter $iCBRed = 0 $iCBGreen = 0 $iCBBlue = 0 EndIf _EnableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) Case $hLevels_Btn _DisableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) $aClone = BitmapApplyEffect($hClone, $hGraphics, $iWidth, $iHeight, $iGUIWidth, $iGUIHeight, "Levels", "Levels - Highlight", $iHighlight, 100, 0, "Midtone", $iMidtone, 100, -100, "Shadow", $iShadow, 100, 0) If Not @error Then $hClone = $aClone[0] $iHighlight = $aClone[1] $iMidtone = $aClone[2] $iShadow = $aClone[3] ReDim $aEffectsHistory[$aEffectsHistory[0][0] + 2][4] $aEffectsHistory[0][0] += 1 $aEffectsHistory[$aEffectsHistory[0][0]][0] = "Levels" $aEffectsHistory[$aEffectsHistory[0][0]][1] = $iHighlight $aEffectsHistory[$aEffectsHistory[0][0]][2] = $iMidtone $aEffectsHistory[$aEffectsHistory[0][0]][3] = $iShadow ; reset values because applied destructive filter $iHighlight = 100 $iMidtone = 0 $iShadow = 0 EndIf _EnableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) Case $h_Sharpen_Btn _DisableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) #cs Note: if the image is scaled, the Radius of the Sharpen will be limited according to the scale. A maximum Sharpen Radius of 255, gives a different result depending on the size of the image, as we want the same result on screen as on the larger final result, we need to limit the Radius accordingly #ce $aClone = BitmapApplyEffect($hClone, $hGraphics, $iWidth, $iHeight, $iGUIWidth, $iGUIHeight, "Sharpen", "Sharpen - Radius", $fRadius, 255 * $iScale, 0, "Amount", $fAmount, 100.0, 0.0) If Not @error Then $hClone = $aClone[0] $fRadius = $aClone[1] $fAmount = $aClone[2] ReDim $aEffectsHistory[$aEffectsHistory[0][0] + 2][4] $aEffectsHistory[0][0] += 1 $aEffectsHistory[$aEffectsHistory[0][0]][0] = "Sharpen" $aEffectsHistory[$aEffectsHistory[0][0]][1] = $fRadius $aEffectsHistory[$aEffectsHistory[0][0]][2] = $fAmount ; reset values because applied destructive filter $fRadius = 10 $fAmount = 50 EndIf _EnableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) Case $h_Tint_Btn _DisableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) $aClone = BitmapApplyEffect($hClone, $hGraphics, $iWidth, $iHeight, $iGUIWidth, $iGUIHeight, "Tint", "Tint - Hue", $iTintHue, 180, -180, "Amount", $iTintAmount, 100, -100) If Not @error Then $hClone = $aClone[0] $iTintHue = $aClone[1] $iTintAmount = $aClone[2] ReDim $aEffectsHistory[$aEffectsHistory[0][0] + 2][4] $aEffectsHistory[0][0] += 1 $aEffectsHistory[$aEffectsHistory[0][0]][0] = "Tint" $aEffectsHistory[$aEffectsHistory[0][0]][1] = $iTintHue $aEffectsHistory[$aEffectsHistory[0][0]][2] = $iTintAmount ; reset values because applied destructive filter $iTintHue = 0 $iTintAmount = 0 EndIf _EnableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) Case $h_Undo_Btn If $aEffectsHistory[0][0] = 0 Then ContinueLoop MsgBox(48, "Info", "No effects have been applied yet") ;~ _ArrayDisplay($aEffectsHistory, @ScriptLineNumber) _DisableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) Local $hListviewLabel, $hlistview, $hBtnOK, $hBtnCancel, $msg2, $iListViewSelected = $aEffectsHistory[0][0], $hEffect $hListviewLabel = GUICtrlCreateGroup("Undo", ($iGUIWidth/2) + 8, $iHeight + 10, 280, $iGUIHeight - $iHeight - 35) $hlistview = GUICtrlCreateListView("Listview", ($iGUIWidth/2) + 12, $iHeight + 25, 270, $iGUIHeight - $iHeight - 55, BitOR($LVS_NOCOLUMNHEADER, $LVS_SHOWSELALWAYS, $LVS_SINGLESEL)) GUICtrlCreateListViewItem("Open", $hlistview) For $i = 1 to $aEffectsHistory[0][0] If $aEffectsHistory[$i][0] = "BC" Then GUICtrlCreateListViewItem("Brightness " & $aEffectsHistory[$i][1] & " , Contrast " & $aEffectsHistory[$i][2], $hlistview) ElseIf $aEffectsHistory[$i][0] = "HSL" Then GUICtrlCreateListViewItem("Hue " & $aEffectsHistory[$i][1] & " , Saturation " & $aEffectsHistory[$i][2] & " , Lightness " & $aEffectsHistory[$i][3], $hlistview) ElseIf $aEffectsHistory[$i][0] = "Blur" Then GUICtrlCreateListViewItem("Blur " & $aEffectsHistory[$i][1], $hlistview) ElseIf $aEffectsHistory[$i][0] = "ColBal" Then GUICtrlCreateListViewItem("Color Balance: Red " & $aEffectsHistory[$i][1] & " , Green " & $aEffectsHistory[$i][2] & " , Blue " & $aEffectsHistory[$i][3], $hlistview) ElseIf $aEffectsHistory[$i][0] = "Levels" Then GUICtrlCreateListViewItem("Levels; Highlight " & $aEffectsHistory[$i][1] & " , Midtone " & $aEffectsHistory[$i][2] & " , Shadow " & $aEffectsHistory[$i][3], $hlistview) ElseIf $aEffectsHistory[$i][0] = "Sharpen" Then GUICtrlCreateListViewItem("Sharpen: Radius " & $aEffectsHistory[$i][1] & " , Amount " & $aEffectsHistory[$i][2], $hlistview) ElseIf $aEffectsHistory[$i][0] = "Tint" Then GUICtrlCreateListViewItem("Tint: Hue " & $aEffectsHistory[$i][1] & " , Amount " & $aEffectsHistory[$i][2], $hlistview) Else ; in case I forgot... GUICtrlCreateListViewItem($aEffectsHistory[$i][0], $hlistview) EndIf Next ; Finished - Change the column width to fit the item text ;GUICtrlSendMsg($hlistview, $LVM_SETCOLUMNWIDTH, 0, -1) GUICtrlSendMsg($hlistview, $LVM_SETCOLUMNWIDTH, 0, -2) ; title ;ConsoleWrite( @ScriptLineNumber & " " & $iListViewSelected & @CRLF) _GUICtrlListView_SetItemSelected($hListView, $iListViewSelected) ; set selct on last row $hBtnOK = GUICtrlCreateButton("OK", $iGUIWidth - 120, $iGUIHeight -90, 110, 30) $hBtnCancel = GUICtrlCreateButton("Cancel", $iGUIWidth - 120, $iGUIHeight -55, 110, 30) While 1 $msg2 = GUIGetMsg() Switch $msg2 Case $hBtnOK ; cleanup history array For $i = $aEffectsHistory[0][0] to $iListViewSelected + 1 Step -1 _ArrayDelete($aEffectsHistory, $i) Next $aEffectsHistory[0][0] = $iListViewSelected GUICtrlDelete($hListviewLabel) GUICtrlDelete($hlistview) GUICtrlDelete($hBtnOK) GUICtrlDelete($hBtnCancel) _EnableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) ExitLoop Case $hBtnCancel _GDIPlus_ImageDispose($hClone) $hClone = _GDIPlus_BitmapCloneArea($hBitmap_original, 0, 0, _GDIPlus_ImageGetWidth($hBitmap_original), _GDIPlus_ImageGetHeight($hBitmap_original)) For $i = 1 To $aEffectsHistory[0][0] If $aEffectsHistory[$i][0] = "BC" Then $hEffect = _GDIPlus_EffectCreateBrightnessContrast($aEffectsHistory[$i][1], $aEffectsHistory[$i][2]) ElseIf $aEffectsHistory[$i][0] = "HSL" Then $hEffect = _GDIPlus_EffectCreateHueSaturationLightness($aEffectsHistory[$i][1], $aEffectsHistory[$i][2], $aEffectsHistory[$i][3]) ElseIf $aEffectsHistory[$i][0] = "Blur" Then $hEffect = _GDIPlus_EffectCreateBlur($aEffectsHistory[$i][1]) ElseIf $aEffectsHistory[$i][0] = "ColBal" Then $hEffect = _GDIPlus_EffectCreateColorBalance($aEffectsHistory[$i][1], $aEffectsHistory[$i][2], $aEffectsHistory[$i][3]) ElseIf $aEffectsHistory[$i][0] = "Levels" Then $hEffect = _GDIPlus_EffectCreateLevels($aEffectsHistory[$i][1], $aEffectsHistory[$i][2], $aEffectsHistory[$i][3]) ElseIf $aEffectsHistory[$i][0] = "Sharpen" Then $hEffect = _GDIPlus_EffectCreateSharpen($aEffectsHistory[$i][1], $aEffectsHistory[$i][2]) ElseIf $aEffectsHistory[$i][0] = "Tint" Then $hEffect = _GDIPlus_EffectCreateTint($aEffectsHistory[$i][1], $aEffectsHistory[$i][2]) EndIf _GDIPlus_BitmapApplyEffect($hClone, $hEffect) Next _GDIPlus_GraphicsDrawImageRect($hGraphics, $hClone, ($iGUIWidth - $iWidth)/2, 0, $iWidth, $iHeight) GUICtrlDelete($hListviewLabel) GUICtrlDelete($hlistview) GUICtrlDelete($hBtnOK) GUICtrlDelete($hBtnCancel) _EnableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) ExitLoop EndSwitch If $iListViewSelected <> _GUICtrlListView_GetSelectedIndices( $hlistview, False ) Then $iListViewSelected = _GUICtrlListView_GetSelectedIndices( $hlistview, False ) ;ConsoleWrite( @ScriptLineNumber & " " & GUICtrlRead(GUICtrlRead($hlistview)) & " <" & _GUICtrlListView_GetSelectedIndices( $hlistview, False ) & ">" & @CRLF) _GDIPlus_ImageDispose($hClone) $hClone = _GDIPlus_BitmapCloneArea($hBitmap_original, 0, 0, _GDIPlus_ImageGetWidth($hBitmap_original), _GDIPlus_ImageGetHeight($hBitmap_original)) For $i = 1 To $iListViewSelected If $aEffectsHistory[$i][0] = "BC" Then $hEffect = _GDIPlus_EffectCreateBrightnessContrast($aEffectsHistory[$i][1], $aEffectsHistory[$i][2]) ElseIf $aEffectsHistory[$i][0] = "HSL" Then $hEffect = _GDIPlus_EffectCreateHueSaturationLightness($aEffectsHistory[$i][1], $aEffectsHistory[$i][2], $aEffectsHistory[$i][3]) ElseIf $aEffectsHistory[$i][0] = "Blur" Then $hEffect = _GDIPlus_EffectCreateBlur($aEffectsHistory[$i][1]) ElseIf $aEffectsHistory[$i][0] = "ColBal" Then $hEffect = _GDIPlus_EffectCreateColorBalance($aEffectsHistory[$i][1], $aEffectsHistory[$i][2], $aEffectsHistory[$i][3]) ElseIf $aEffectsHistory[$i][0] = "Levels" Then $hEffect = _GDIPlus_EffectCreateLevels($aEffectsHistory[$i][1], $aEffectsHistory[$i][2], $aEffectsHistory[$i][3]) ElseIf $aEffectsHistory[$i][0] = "Sharpen" Then $hEffect = _GDIPlus_EffectCreateSharpen($aEffectsHistory[$i][1], $aEffectsHistory[$i][2]) ElseIf $aEffectsHistory[$i][0] = "Tint" Then $hEffect = _GDIPlus_EffectCreateTint($aEffectsHistory[$i][1], $aEffectsHistory[$i][2]) EndIf _GDIPlus_BitmapApplyEffect($hClone, $hEffect) Next _GDIPlus_GraphicsDrawImageRect($hGraphics, $hClone, ($iGUIWidth - $iWidth)/2, 0, $iWidth, $iHeight) EndIf sleep(10) WEnd EndSwitch Sleep(10) WEnd EndFunc ;==>_ImageEffects Func _DisableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) GUICtrlSetState($h_BC_Btn, $GUI_DISABLE) GUICtrlSetState($h_HSL_Btn, $GUI_DISABLE) GUICtrlSetState($h_Blur_Btn, $GUI_DISABLE) GUICtrlSetState($h_ColBal_Btn, $GUI_DISABLE) GUICtrlSetState($hLevels_Btn, $GUI_DISABLE) GUICtrlSetState($h_Sharpen_Btn, $GUI_DISABLE) GUICtrlSetState($h_Tint_Btn, $GUI_DISABLE) GUICtrlSetState($h_Undo_Btn, $GUI_DISABLE) GUICtrlSetState($hSaveBtn2, $GUI_DISABLE) GUICtrlSetState($hCloseBtn2, $GUI_DISABLE) GUICtrlSetState($hFileMenu, $GUI_DISABLE) EndFunc ;==>_DisableButtons Func _EnableButtons($h_BC_Btn, $h_HSL_Btn, $h_Blur_Btn, $h_ColBal_Btn, $hLevels_Btn, $h_Sharpen_Btn, $h_Tint_Btn, $h_Undo_Btn, $hSaveBtn2, $hCloseBtn2, $hFileMenu) GUICtrlSetState($h_BC_Btn, $GUI_ENABLE) GUICtrlSetState($h_HSL_Btn, $GUI_ENABLE) GUICtrlSetState($h_Blur_Btn, $GUI_ENABLE) GUICtrlSetState($h_ColBal_Btn, $GUI_ENABLE) GUICtrlSetState($hLevels_Btn, $GUI_ENABLE) GUICtrlSetState($h_Sharpen_Btn, $GUI_ENABLE) GUICtrlSetState($h_Tint_Btn, $GUI_ENABLE) GUICtrlSetState($h_Undo_Btn, $GUI_ENABLE) GUICtrlSetState($hSaveBtn2, $GUI_ENABLE) GUICtrlSetState($hCloseBtn2, $GUI_ENABLE) GUICtrlSetState($hFileMenu, $GUI_ENABLE) EndFunc ;==>_EnableButtons Func BitmapApplyEffect($hBitmap_Scaled, $hGraphics, $iWidth, $iHeight, $iGUIWidth, $iGUIHeight, $sEffect, _ $sSliderLabel1, $iSlider1Value, $iSlider1Max, $iSlider1Min, _ $sSliderLabel2 = "", $iSlider2Value = 0, $iSlider2Max = 0, $iSlider2Min = 0, _ $sSliderLabel3 = "", $iSlider3Value = 0, $iSlider3Max = 0, $iSlider3Min = 0) Local $hBtnReset, $hBtnOK, $hBtnCancel, $msg, $hClone, $hEffect Local $iSlider1Value_reset = $iSlider1Value, $iSlider2Value_reset = $iSlider2Value, $iSlider3Value_reset = $iSlider3Value ; initial settings required for reset Local $iSlider1Value_keep, $iSlider2Value_keep, $iSlider3Value_keep ; keep variation of slider Local $hSlider1Label, $hSlider1, $hSlider1Val, $hSlider2Label, $hSlider2, $hSlider2Val, $hSlider3Label, $hSlider3, $hSlider3Val ; slider 1 $hSlider1Label = GUICtrlCreateGroup($sSliderLabel1, ($iGUIWidth/2) + 8, $iHeight + 10, ($iGUIWidth/2) - 17, 45) $hSlider1Val = GUICtrlCreateLabel($iSlider1Value, ($iGUIWidth/2) + ($iGUIWidth/4) - 10, $iHeight + 10, 20, 20, $SS_CENTER) GUICtrlSetColor(-1,0xFF0000) $hSlider1 = GUICtrlCreateSlider(($iGUIWidth/2) + 10, $iHeight + 23, ($iGUIWidth/2) - 20, 25) GUICtrlSetLimit(-1, $iSlider1Max, $iSlider1Min) GUICtrlSetData(-1, $iSlider1Value) If $sSliderLabel2 <> "" Then ; slider 2 $hSlider2Label = GUICtrlCreateGroup($sSliderLabel2, ($iGUIWidth/2) + 8, $iHeight + 60, ($iGUIWidth/2) - 17, 45) $hSlider2Val = GUICtrlCreateLabel($iSlider2Value, ($iGUIWidth/2) + ($iGUIWidth/4) - 10, $iHeight + 60, 20, 20, $SS_CENTER) GUICtrlSetColor(-1,0xFF0000) $hSlider2 = GUICtrlCreateSlider(($iGUIWidth/2) + 10, $iHeight + 73, ($iGUIWidth/2) - 20, 25) GUICtrlSetLimit(-1, $iSlider2Max, $iSlider2Min) GUICtrlSetData(-1, $iSlider2Value) EndIf If $sSliderLabel3 <> "" Then ; slider 3 $hSlider3Label = GUICtrlCreateGroup($sSliderLabel3, ($iGUIWidth/2) + 8, $iHeight + 110, ($iGUIWidth/2) - 17, 45) $hSlider3Val = GUICtrlCreateLabel($iSlider3Value, ($iGUIWidth/2) + ($iGUIWidth/4) - 10, $iHeight + 110, 20, 20, $SS_CENTER) GUICtrlSetColor(-1,0xFF0000) $hSlider3 = GUICtrlCreateSlider(($iGUIWidth/2) + 10, $iHeight + 123, ($iGUIWidth/2) - 20, 25) GUICtrlSetLimit(-1, $iSlider3Max, $iSlider3Min) GUICtrlSetData(-1, $iSlider3Value) EndIf $hBtnReset = GUICtrlCreateButton("Reset", ($iGUIWidth/2) + 10, $iGUIHeight -55, 110, 30) $hBtnOK = GUICtrlCreateButton("OK", $iGUIWidth - 240, $iGUIHeight -55, 110, 30) $hBtnCancel = GUICtrlCreateButton("Cancel", $iGUIWidth - 120, $iGUIHeight -55, 110, 30) $iSlider1Value_keep = GUICtrlRead($hSlider1) If $sSliderLabel2 <> "" Then $iSlider2Value_keep = GUICtrlRead($hSlider2) If $sSliderLabel3 <> "" Then $iSlider3Value_keep = GUICtrlRead($hSlider3) While 1 $msg = GUIGetMsg() $iSlider1Value = GUICtrlRead($hSlider1) If $sSliderLabel2 <> "" Then $iSlider2Value = GUICtrlRead($hSlider2) If $sSliderLabel3 <> "" Then $iSlider3Value = GUICtrlRead($hSlider3) If $msg = $hBtnCancel Then GUICtrlDelete($hSlider1Label) GUICtrlDelete($hSlider1Val) GUICtrlDelete($hSlider1) If $sSliderLabel2 <> "" Then GUICtrlDelete($hSlider2Label) GUICtrlDelete($hSlider2Val) GUICtrlDelete($hSlider2) If $sSliderLabel3 <> "" Then GUICtrlDelete($hSlider3Label) GUICtrlDelete($hSlider3Val) GUICtrlDelete($hSlider3) EndIf EndIf GUICtrlDelete($hBtnReset) GUICtrlDelete($hBtnOK) GUICtrlDelete($hBtnCancel) ; reset image $hClone = _GDIPlus_BitmapCloneArea($hBitmap_Scaled, 0, 0, _GDIPlus_ImageGetWidth($hBitmap_Scaled), _GDIPlus_ImageGetHeight($hBitmap_Scaled)) $iSlider1Value = $iSlider1Value_reset If $sSliderLabel2 <> "" Then $iSlider2Value = $iSlider2Value_reset If $sSliderLabel3 <> "" Then $iSlider3Value = $iSlider3Value_reset If $sEffect = "BC" Then $hEffect = _GDIPlus_EffectCreateBrightnessContrast($iSlider1Value, $iSlider2Value) ElseIf $sEffect = "HSL" Then $hEffect = _GDIPlus_EffectCreateHueSaturationLightness($iSlider1Value, $iSlider2Value, $iSlider3Value) ElseIf $sEffect = "Blur" Then $hEffect = _GDIPlus_EffectCreateBlur($iSlider1Value) ElseIf $sEffect = "ColBal" Then $hEffect = _GDIPlus_EffectCreateColorBalance($iSlider1Value, $iSlider2Value, $iSlider3Value) ElseIf $sEffect = "Levels" Then $hEffect = _GDIPlus_EffectCreateLevels($iSlider1Value, $iSlider2Value, $iSlider3Value) ElseIf $sEffect = "Sharpen" Then $hEffect = _GDIPlus_EffectCreateSharpen($iSlider1Value, $iSlider2Value) ElseIf $sEffect = "Tint" Then $hEffect = _GDIPlus_EffectCreateTint($iSlider1Value, $iSlider2Value) EndIf _GDIPlus_BitmapApplyEffect($hClone, $hEffect) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hClone, ($iGUIWidth - $iWidth)/2, 0, $iWidth, $iHeight) Return SetError(1, 0, 0) ElseIf $msg = $hBtnOK Then GUICtrlDelete($hSlider1Label) GUICtrlDelete($hSlider1Val) GUICtrlDelete($hSlider1) If $sSliderLabel2 <> "" Then GUICtrlDelete($hSlider2Label) GUICtrlDelete($hSlider2Val) GUICtrlDelete($hSlider2) If $sSliderLabel3 <> "" Then GUICtrlDelete($hSlider3Label) GUICtrlDelete($hSlider3Val) GUICtrlDelete($hSlider3) EndIf EndIf GUICtrlDelete($hBtnReset) GUICtrlDelete($hBtnOK) GUICtrlDelete($hBtnCancel) Local $aClone[4] = [$hClone, $iSlider1Value, $iSlider2Value,$iSlider3Value] Return $aClone ElseIf $msg = $hBtnReset Then ; reset image $iSlider1Value = $iSlider1Value_reset $iSlider1Value_keep = $iSlider1Value GUICtrlSetData($hSlider1Val, $iSlider1Value) GUICtrlSetData($hSlider1, $iSlider1Value) If $sSliderLabel2 <> "" Then $iSlider2Value = $iSlider2Value_reset $iSlider2Value_keep = $iSlider2Value GUICtrlSetData($hSlider2Val, $iSlider2Value) GUICtrlSetData($hSlider2, $iSlider2Value) If $sSliderLabel3 <> "" Then $iSlider3Value = $iSlider1Value_reset $iSlider3Value_keep = $iSlider3Value GUICtrlSetData($hSlider3Val, $iSlider3Value) GUICtrlSetData($hSlider3, $iSlider3Value) EndIf EndIf $hClone = _GDIPlus_BitmapCloneArea($hBitmap_Scaled, 0, 0, _GDIPlus_ImageGetWidth($hBitmap_Scaled), _GDIPlus_ImageGetHeight($hBitmap_Scaled)) If $sEffect = "BC" Then $hEffect = _GDIPlus_EffectCreateBrightnessContrast($iSlider1Value, $iSlider2Value) ElseIf $sEffect = "HSL" Then $hEffect = _GDIPlus_EffectCreateHueSaturationLightness($iSlider1Value, $iSlider2Value, $iSlider3Value) ElseIf $sEffect = "Blur" Then $hEffect = _GDIPlus_EffectCreateBlur($iSlider1Value) ElseIf $sEffect = "ColBal" Then $hEffect = _GDIPlus_EffectCreateColorBalance($iSlider1Value, $iSlider2Value, $iSlider3Value) ElseIf $sEffect = "Levels" Then $hEffect = _GDIPlus_EffectCreateLevels($iSlider1Value, $iSlider2Value, $iSlider3Value) ElseIf $sEffect = "Sharpen" Then $hEffect = _GDIPlus_EffectCreateSharpen($iSlider1Value, $iSlider2Value) ElseIf $sEffect = "Tint" Then $hEffect = _GDIPlus_EffectCreateTint($iSlider1Value, $iSlider2Value) EndIf _GDIPlus_BitmapApplyEffect($hClone, $hEffect) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hClone, ($iGUIWidth - $iWidth)/2, 0, $iWidth, $iHeight) ElseIf $iSlider1Value_keep <> $iSlider1Value Then ; brightness $iSlider1Value_keep = $iSlider1Value GUICtrlSetData($hSlider1Val, $iSlider1Value) _GDIPlus_ImageDispose($hClone) $hClone = _GDIPlus_BitmapCloneArea($hBitmap_Scaled, 0, 0, _GDIPlus_ImageGetWidth($hBitmap_Scaled), _GDIPlus_ImageGetHeight($hBitmap_Scaled)) If $sEffect = "BC" Then $hEffect = _GDIPlus_EffectCreateBrightnessContrast($iSlider1Value, $iSlider2Value) ElseIf $sEffect = "HSL" Then $hEffect = _GDIPlus_EffectCreateHueSaturationLightness($iSlider1Value, $iSlider2Value, $iSlider3Value) ElseIf $sEffect = "Blur" Then $hEffect = _GDIPlus_EffectCreateBlur($iSlider1Value) ElseIf $sEffect = "ColBal" Then $hEffect = _GDIPlus_EffectCreateColorBalance($iSlider1Value, $iSlider2Value, $iSlider3Value) ElseIf $sEffect = "Levels" Then $hEffect = _GDIPlus_EffectCreateLevels($iSlider1Value, $iSlider2Value, $iSlider3Value) ElseIf $sEffect = "Sharpen" Then $hEffect = _GDIPlus_EffectCreateSharpen($iSlider1Value, $iSlider2Value) ElseIf $sEffect = "Tint" Then $hEffect = _GDIPlus_EffectCreateTint($iSlider1Value, $iSlider2Value) EndIf _GDIPlus_BitmapApplyEffect($hClone, $hEffect) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hClone, ($iGUIWidth - $iWidth)/2, 0, $iWidth, $iHeight) ElseIf $iSlider2Value_keep <> $iSlider2Value Then ; contrast $iSlider2Value_keep = $iSlider2Value GUICtrlSetData($hSlider2Val, $iSlider2Value) _GDIPlus_ImageDispose($hClone) $hClone = _GDIPlus_BitmapCloneArea($hBitmap_Scaled, 0, 0, _GDIPlus_ImageGetWidth($hBitmap_Scaled), _GDIPlus_ImageGetHeight($hBitmap_Scaled)) If $sEffect = "BC" Then $hEffect = _GDIPlus_EffectCreateBrightnessContrast($iSlider1Value, $iSlider2Value) ElseIf $sEffect = "HSL" Then $hEffect = _GDIPlus_EffectCreateHueSaturationLightness($iSlider1Value, $iSlider2Value, $iSlider3Value) ElseIf $sEffect = "Blur" Then $hEffect = _GDIPlus_EffectCreateBlur($iSlider1Value) ElseIf $sEffect = "ColBal" Then $hEffect = _GDIPlus_EffectCreateColorBalance($iSlider1Value, $iSlider2Value, $iSlider3Value) ElseIf $sEffect = "Levels" Then $hEffect = _GDIPlus_EffectCreateLevels($iSlider1Value, $iSlider2Value, $iSlider3Value) ElseIf $sEffect = "Sharpen" Then $hEffect = _GDIPlus_EffectCreateSharpen($iSlider1Value, $iSlider2Value) ElseIf $sEffect = "Tint" Then $hEffect = _GDIPlus_EffectCreateTint($iSlider1Value, $iSlider2Value) EndIf _GDIPlus_BitmapApplyEffect($hClone, $hEffect) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hClone, ($iGUIWidth - $iWidth)/2, 0, $iWidth, $iHeight) ElseIf $iSlider3Value_keep <> $iSlider3Value Then ; contrast $iSlider3Value_keep = $iSlider3Value GUICtrlSetData($hSlider3Val, $iSlider3Value) _GDIPlus_ImageDispose($hClone) $hClone = _GDIPlus_BitmapCloneArea($hBitmap_Scaled, 0, 0, _GDIPlus_ImageGetWidth($hBitmap_Scaled), _GDIPlus_ImageGetHeight($hBitmap_Scaled)) If $sEffect = "BC" Then $hEffect = _GDIPlus_EffectCreateBrightnessContrast($iSlider1Value, $iSlider2Value) ElseIf $sEffect = "HSL" Then $hEffect = _GDIPlus_EffectCreateHueSaturationLightness($iSlider1Value, $iSlider2Value, $iSlider3Value) ElseIf $sEffect = "Blur" Then $hEffect = _GDIPlus_EffectCreateBlur($iSlider1Value) ElseIf $sEffect = "ColBal" Then $hEffect = _GDIPlus_EffectCreateColorBalance($iSlider1Value, $iSlider2Value, $iSlider3Value) ElseIf $sEffect = "Levels" Then $hEffect = _GDIPlus_EffectCreateLevels($iSlider1Value, $iSlider2Value, $iSlider3Value) ElseIf $sEffect = "Sharpen" Then $hEffect = _GDIPlus_EffectCreateSharpen($iSlider1Value, $iSlider2Value) ElseIf $sEffect = "Tint" Then $hEffect = _GDIPlus_EffectCreateTint($iSlider1Value, $iSlider2Value) EndIf _GDIPlus_BitmapApplyEffect($hClone, $hEffect) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hClone, ($iGUIWidth - $iWidth)/2, 0, $iWidth, $iHeight) EndIf Sleep(10) WEnd EndFunc ;==>BitmapApplyEffect Func _SaveClone($sFileName, $hClone) ; this function saves the cloned (eventually cropped image) with loss of quality Local $iError = 0 Local $sImageDir = StringLeft($sFileName, StringInStr($sFileName, "\", 0, -1) - 1) Local $sFileExtension = StringTrimLeft($sFileName, StringInStr($sFileName, ".", 0, -1)) Local $sImageFileName = StringTrimRight(StringRight($sFileName, StringLen($sFileName) - StringInStr($sFileName, "\", 0, -1)), StringLen($sFileExtension)+1) Local $sNewFilename = $sImageDir & "\" & $sImageFileName & "_mod" & "." & $sFileExtension FileDelete($sNewFilename) ; if exists, delete it _GDIPlus_ImageSaveToFile($hClone, $sNewFilename) ; strange error handling with this function, not consistent! checking if file exists, that is at least correct If Not FileExists($sNewFilename) Then $iError = 1 $sNewFilename = "" EndIf _WinAPI_DeleteObject($hClone) Return SetError($iError, 0, $sNewFilename) EndFunc ;==>_SaveClone Func _SaveLossless($sFileName, $hBitmap_original, $aEffectsHistory, $iScale) ; this function saves the modified original loaded bitmap lossless Local $hClone, $hEffect, $iError = 0 Local $sImageDir = StringLeft($sFileName, StringInStr($sFileName, "\", 0, -1) - 1) Local $sFileExtension = StringTrimLeft($sFileName, StringInStr($sFileName, ".", 0, -1)) Local $sImageFileName = StringTrimRight(StringRight($sFileName, StringLen($sFileName) - StringInStr($sFileName, "\", 0, -1)), StringLen($sFileExtension)+1) Local $sNewFilename = $sImageDir & "\" & $sImageFileName & "_mod2" & "." & $sFileExtension ;_ArrayDisplay($aEffectsHistory, @ScriptLineNumber) _GDIPlus_ImageDispose($hClone) $hClone = _GDIPlus_BitmapCloneArea($hBitmap_original, 0, 0, _GDIPlus_ImageGetWidth($hBitmap_original), _GDIPlus_ImageGetHeight($hBitmap_original)) For $i = 1 To $aEffectsHistory[0][0] If $aEffectsHistory[$i][0] = "BC" Then $hEffect = _GDIPlus_EffectCreateBrightnessContrast($aEffectsHistory[$i][1], $aEffectsHistory[$i][2]) ElseIf $aEffectsHistory[$i][0] = "HSL" Then $hEffect = _GDIPlus_EffectCreateHueSaturationLightness($aEffectsHistory[$i][1], $aEffectsHistory[$i][2], $aEffectsHistory[$i][3]) ElseIf $aEffectsHistory[$i][0] = "Blur" Then ; Blur Radius should be increased by scale factor to obtain 'similar' result ;ConsoleWrite(@ScriptLineNumber & " " & $iScale & " " & $aEffectsHistory[$i][1] & " factor: " & $aEffectsHistory[$i][1] / $iScale & @CRLF) $hEffect = _GDIPlus_EffectCreateBlur($aEffectsHistory[$i][1] / $iScale) ElseIf $aEffectsHistory[$i][0] = "ColBal" Then $hEffect = _GDIPlus_EffectCreateColorBalance($aEffectsHistory[$i][1], $aEffectsHistory[$i][2], $aEffectsHistory[$i][3]) ElseIf $aEffectsHistory[$i][0] = "Levels" Then $hEffect = _GDIPlus_EffectCreateLevels($aEffectsHistory[$i][1], $aEffectsHistory[$i][2], $aEffectsHistory[$i][3]) ElseIf $aEffectsHistory[$i][0] = "Sharpen" Then ; Sharpen Radius should be increased by scale factor to obtain similar result $hEffect = _GDIPlus_EffectCreateSharpen($aEffectsHistory[$i][1] / $iScale, $aEffectsHistory[$i][2]) ElseIf $aEffectsHistory[$i][0] = "Tint" Then $hEffect = _GDIPlus_EffectCreateTint($aEffectsHistory[$i][1], $aEffectsHistory[$i][2]) EndIf _GDIPlus_BitmapApplyEffect($hClone, $hEffect) ; this line will save a bitmap of every step of the effect, test purpose only ; _GDIPlus_ImageSaveToFile($hClone, $sImageDir & "\" & $sImageFileName & "_mod2_" & $i & "." & $sFileExtension) Next FileDelete($sNewFilename) ; if exists, delete it _GDIPlus_ImageSaveToFile($hClone, $sNewFilename) ; strange error handling with this function, not consistent! checking if file exists, that is at least correct If Not FileExists($sNewFilename) Then $iError = 1 $sNewFilename = "" EndIf _WinAPI_DeleteObject($hClone) Return SetError($iError, 0, $sNewFilename) EndFunc ;==>_SaveLossless Func _Lowest($iNumber1, $iNumber2) Return ( $iNumber1 < $iNumber2 ? $iNumber1 : $iNumber2 ) EndFunc Func _Highest($iNumber1, $iNumber2) Return ( $iNumber1 > $iNumber2 ? $iNumber1 : $iNumber2 ) EndFunc