Jump to content

_GDIPlus_BitmapApplyFilter v0.9.8 build 2024-04-17 beta


UEZ
 Share

Recommended Posts

Added 8 more filters (Convolution_Gaussian3x3, Median2, Time Warp, Fish Eye, Swirl, Wave, X-Ray, Distortion Blur).

 

Have fun. ;)

 

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

  • 3 years later...

Hello everyone, i have been scripting for a while without the need for registration.

I have immensely benefitted from the forums with all these great examples and scripts and great support, even without asking a question!

However i had to ask a specific question about this UDF developed by UEZ, i tried to pm him but i couldn't, i'm a newbie here.

I had to use these filters for preprocessing for OCR. Specifically i need Unsharp masking with gaussian kernel that i can modify maybe add a threshold for nearby color gradients like in imagemagick example,  " -unsharp 0x6+1+0.30 ", i followed UEZ's modified dll all the way to FreeBasic. Then i have realized there is an 31. option for Convolution Filter in the dll that is not passed to UDF, is this intentional ?

Then i also need to ask, why Freebasic? Im a noob scripter, when it comes to dll's and languages i dont really understand how it benefits ?

Can we write it in autoit? Can we not add these functions to autoit itself? Do we really need a dll, and why specifically a dll written in another language?

These are my noob questions, any lead i would really appreciate.

I cannot show enough gratitude for autoit community and developers, and UEZ you are one of my favourite developer. I appreciate your efforts.

Have a good day everyone!

Link to comment
Share on other sites

2 hours ago, novel said:

Hello everyone, i have been scripting for a while without the need for registration.

I have immensely benefitted from the forums with all these great examples and scripts and great support, even without asking a question!

However i had to ask a specific question about this UDF developed by UEZ, i tried to pm him but i couldn't, i'm a newbie here.

I had to use these filters for preprocessing for OCR. Specifically i need Unsharp masking with gaussian kernel that i can modify maybe add a threshold for nearby color gradients like in imagemagick example,  " -unsharp 0x6+1+0.30 ", i followed UEZ's modified dll all the way to FreeBasic. Then i have realized there is an 31. option for Convolution Filter in the dll that is not passed to UDF, is this intentional ?

Then i also need to ask, why Freebasic? Im a noob scripter, when it comes to dll's and languages i dont really understand how it benefits ?

Can we write it in autoit? Can we not add these functions to autoit itself? Do we really need a dll, and why specifically a dll written in another language?

These are my noob questions, any lead i would really appreciate.

I cannot show enough gratitude for autoit community and developers, and UEZ you are one of my favourite developer. I appreciate your efforts.

Have a good day everyone!

I don't know what you mean with 31. option?

The reason why had used a DLL is simple: speed.

As you might know Autoit is an interpreter which translates the commands in real-time instead of compiling the code. That means for graphical operations such as pixel manipulation the speed is simply not sufficient. Even with the DLL some operations may take some seconds.

Of course all the functions can be written with Autoit but you don't need a cup of coffee rather a bucket of coffee for the waiting time. ;) 

If you want you can try to translate these function to Autoit -> _GDIPlus_BitmapApplyFilter v0.9.7 build 2020-11-16 beta (Windows only)

Btw, I've added some more functions (e.g. Delaunay) to the DLL but didn't publish it due to lack of interest.

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

1 hour ago, UEZ said:

I don't know what you mean with 31. option?

The reason why had used a DLL is simple: speed.

As you might know Autoit is an interpreter which translates the commands in real-time instead of compiling the code. That means for graphical operations such as pixel manipulation the speed is simply not sufficient. Even with the DLL some operations may take some seconds.

Of course all the functions can be written with Autoit but you don't need a cup of coffee rather a bucket of coffee for the waiting time. ;) 

If you want you can try to translate these function to Autoit -> _GDIPlus_BitmapApplyFilter v0.9.7 build 2020-11-16 beta (Windows only)

Btw, I've added some more functions (e.g. Delaunay) to the DLL but didn't publish it due to lack of interest.

Thanks for the reply, i understand now the reason behind it.

Link to comment
Share on other sites

Actually i would like to help but i couldnt move with the code in pastebin, when i tried to compile it i received several errors, one was related with the crt.bi i fixed it, i think the code is several years old and the FBEdit Ide has issues with it, i dont remember atm.

Then it didnt find delaunay lib, when i checked in freebasic forums, i couldnt compile the delaunay function because of many errors, i couldnt help myself and i have ended up here :/

Thanks anyway, i wasn't expecting a fast reply.

Link to comment
Share on other sites

Just check out this link: http://www.mediafire.com/file/7y07a02epruem4e/_GDIPlus_BitmapApplyFilter_FB_Examples_build_2020-11-16.7z/file

Within this package you should find all needed files including some FB examples.

Here the Autoit UDF for it:

;IMPORTANT: You are not allowed to sell this code or just parts of it in a commercial project or modify it and distribute it with a different name!
;Distributing copies of this UDF incl. _GDIPlus_BitmapApplyFilter.dll in compiled format (exe) must be free of any fee!
;
;coded by UEZ build 2020-11-16 beta
;

#include-once
#include <GDIPlus.au3>

Global $__hDLL__FX__
Global Enum $EMBOSS1 = 1, $EMBOSS2, $EMBOSS3, $EMBOSS4, $SHARPEN1, $BOX_BLUR, $GAUSSIAN_BLUR, $TRIANGLE_BLUR, $UNSHARP, $UNSHARP5x5, _
        $EDGE_DETECTION1, $EDGE_DETECTION2, $EDGE_DETECTION3, $EDGE_DETECTION4, $EDGE_DETECTION5, $EDGE_DETECTION6, _
        $ANOTHER_BLUR, $MOTION_BLUR, $SHARPEN2, $SOBEL, $LAPLACE3x3_1, $LAPLACE3x3_2, $LAPLACE5x5, $PREWITT, $KIRSCH, _
        $OUTLINE3X3, $GAUSSIAN5X5_1, $GAUSSIAN5X5_2, $LAPLACIANOFGAUSSIAN, $SOVELVSPREWITT, $GAUSSIAN3X3


; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Open
; Description ...: Initialises the DLL and starts GDIPlus
; Syntax ........: _GDIPlus_BitmapApplyFilter_Open([$sPath = @ScriptDir & "\_GDIPlus_BitmapApplyFilter.dll"])
; Parameters ....: $sPath               - [optional] a string value. Default is @ScriptDir & "\_GDIPlus_BitmapApplyFilter.dll".
; Return values .: A dll "handle".
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Open($sPath = @ScriptDir & "\_GDIPlus_BitmapApplyFilter.dll")
    _GDIPlus_Startup()
    If @error Then Return SetError(1, 0, 0)
    If Not FileExists($sPath) Then Return SetError(2, 0, 0)
    $__hDLL__FX__ = DllOpen($sPath)
    If $__hDLL__FX__ = -1 Then Return SetError(3, 0, 0)
    Return $__hDLL__FX__
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Open

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Close
; Description ...: Shut down GDIPlus and close the DLL handle.
; Syntax ........: _GDIPlus_BitmapApplyFilter_Close()
; Parameters ....:
; Return values .: None
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Close()
    DllClose($__hDLL__FX__)
    _GDIPlus_Shutdown()
    Return 1
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Close

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Ver
; Description ...: Displays the version information about the _GDIPlus_BitmapApplyFilter.dll in a MessageBox.
; Syntax ........: _GDIPlus_BitmapApplyFilter_Ver()
; Parameters ....: None
; Return values .: None
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Ver()
    DllCall($__hDLL__FX__, "none", "Ver")
    Return 1
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Ver


; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_SymmetricNearestNeighbour
; Description ...: A smoothing (noise reduction) filter. The SNN smoothing filter is designed to preserve edges in data and
;                  is very effective at noise reduction.
; Syntax ........: _GDIPlus_BitmapApplyFilter_SymmetricNearestNeighbour($hImage, $fRadius[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $fRadius             - a floating point value. The higher the value the more time will needed for calculation.
;                                         The value is limited between 1 and 25.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will
;                                         be returned, otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_SymmetricNearestNeighbour($hImage, $fRadius, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_SymmetricNearestNeighbour", "ptr", $hImage, "float", $fRadius, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_SymmetricNearestNeighbour

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Jitter
; Description ...: Jitters the image
; Syntax ........: _GDIPlus_BitmapApplyFilter_Jitter($hImage, $iAmount[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $iAmount             - an integer value. The amount of jitter strength the image will be modified.
;                                         The higher the value the more the image will be jittered.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Jitter($hImage, $iAmount, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Jitter", "ptr", $hImage, "uint", $iAmount, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Jitter

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Median
; Description ...: A smoothing (noise reduction) filter. The median filter is well known as an edge-preserving smoothing filter.
; Syntax ........: _GDIPlus_BitmapApplyFilter_Median($hImage, $fRadius[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $fRadius             - a floating point value. The higher the value the more time will needed for calculation.
;                                         The value is limited between 1 and 25.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Median($hImage, $fRadius, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Median", "ptr", $hImage, "float", $fRadius, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Median

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Median2
; Description ...: A smoothing (noise reduction) filter. The median filter is well known as an edge-preserving smoothing filter.
; Syntax ........: _GDIPlus_BitmapApplyFilter_Median2($hImage, $fRadius[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $fRadius             - a floating point value. The higher the value the more time will needed for calculation.
;                                         The value is limited between 1 and 25.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......: This filter is faster than _GDIPlus_BitmapApplyFilter_Median but the output quality is lower!
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Median2($hImage, $fRadius, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Median2", "ptr", $hImage, "float", $fRadius, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Median2

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Kuwahara
; Description ...: A smoothing (noise reduction) filter. Like the SNN filter, the Kuwahara filter is an adaptive, edge-preserving
;                  smoothing filter.
; Syntax ........: _GDIPlus_BitmapApplyFilter_Kuwahara($hImage, $iSize[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $iSize               - an integer value. The higher the value the more time will needed for calculation.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Kuwahara($hImage, $iSize, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Kuwahara", "ptr", $hImage, "uint", $iSize, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Kuwahara

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Edges
; Description ...: An edge detecting function based on left neighbour color value.
; Syntax ........: _GDIPlus_BitmapApplyFilter_Edges($hImage, $bMode[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $iMode               - an integer value. If 1 then the colors will be negated.
;                  $bInverse            - [optional] a boolean value. Default is False. If true image will be inverted.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Edges($hImage, $iMode, $bInverse = False, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Edges", "ptr", $hImage, "uByte", $iMode, "bool", $bInverse, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Edges

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Pointillism
; Description ...: Creates an image based on filled ellipses.
; Syntax ........: _GDIPlus_BitmapApplyFilter_Pointillism($hImage, $iRounds, $iSizeEllipse, $iAlpha[, $bBorder = False[,
;                  $bGDI_Bmp = False]])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $iRounds             - an integer value. The amount of drawn filled ellipses.
;                  $iSizeEllipse        - an integer value. The size of the ellipses.
;                  $iAlpha              - an integer value. Alpha color channel. Possible values are between 0 and 255 whereas
;                                         0 is transparent and 255 is opaque.
;                  $bBorder             - [optional] a boolean value. Default is False. If true ellipses will have borders.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Pointillism($hImage, $iRounds, $iSizeEllipse, $iAlpha, $bBorder = False, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Pointillism", "ptr", $hImage, "uint", $iRounds, "uint", $iSizeEllipse, "byte", $iAlpha, "bool", $bBorder, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Pointillism

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Linellism
; Description ...: Creates an image based on filled rectangles (similar to Pointillism fx).
; Syntax ........: _GDIPlus_BitmapApplyFilter_Linellism($hImage, $iRounds, $iSizeRect, $iAlpha[, $iMode = 1[, $bBorder = False[,
;                  $bGDI_Bmp = False]]])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $iRounds             - an integer value. The amount of drawn filled rectangles.
;                  $iSizeRect           - an integer value. The size of the rectangles.
;                  $iAlpha              - an integer value. Alpha color channel. Possible values are between 0 and 255 whereas
;                                         0 is transparent and 255 is opaque.
;                  $iMode               - [optional] an integer value. Default is 1. Direction of the rectangles.
;                                         1 = horizontal, 2 = vertical, 3 = randomly 1 and 2.
;                  $bBorder             - [optional] a boolean value. Default is False. If true ellipses will have borders.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Linellism($hImage, $iRounds, $iSizeRect, $iAlpha, $iMode = 1, $bBorder = False, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Linellism", "ptr", $hImage, "uint", $iRounds, "uint", $iSizeRect, "byte", $iAlpha, "byte", $iMode, "bool", $bBorder, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Linellism

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Convolution
; Description ...: In image processing, a kernel, convolution matrix, or mask is a small matrix useful for blurring, sharpening,
;                  embossing, edge detection, and more. This is accomplished by means of convolution between a kernel and an image.
; Syntax ........: _GDIPlus_BitmapApplyFilter_Convolution($hImage, $fFactor, $fBias[, $iMode = 1[, $bGDI_Bmp = False]])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $fFactor             - a floating point value. Adjustment for the color value (the factor will be multiplied with the result).
;                  $fBias               - a floating point value. Adjustment for the color value (brightness).
;                  $iMode               - [optional] an integer value. Default is 1.
;                                         Convolution modes (matrixes):
;                                         0: Manual odd matrix -> 3x3, 5x5, 7x7, 9x9
;                                         1: Emboss 3x3
;                                         2: Emboss 45 Degree 3x3
;                                         3: Emboss Top Left Bottom Right 3x3
;                                         4: Intense Emboss 5x5
;                                         5: Sharpen 3x3
;                                         6: Box Blur (normalized) 3x3
;                                         7: Gaussian Blur (approximation) 3x3
;                                         8: Triangle Blur 3x3
;                                         9: Unsharp(with no image mask) 5x5
;                                        10: Unsharp 3x3
;                                        11: Edge Detection 1 3x3
;                                        12: Edge Detection 2 3x3
;                                        13: Edge Detection 3 3x3
;                                        14: Edge Detection 4 3x3
;                                        15: Edge Detection 5 3x3
;                                        16: Edge Detection 6 3x3
;                                        17: Another Blur 5x5
;                                        18: Motion Blur 9x9
;                                        19: Sharpen 2 3x3
;                                        20: Sobel 3x3 with 2 matrixes (h/w)
;                                        21: Laplace 3x3 v1
;                                        22: Laplace 3x3 v2
;                                        23: Laplace 5x5
;                                        24: Prewitt 3x3
;                                        25: Kirsch 3x3
;                                        26: Gaussian3x3 blur
;                                        27: Gaussian5x5 Type1 blur
;                                        28: Gaussian5x5 Type2 blur
;                                        29: Laplacian of Gaussian 5x5
;                                        30: Sovel vs Prewitt 3x3
;                  $tMatrix             - [optional] an integer value. Default is 0. You can provide a convolution matrix manually.
;                                         The struct must have same amount of columns & rows whereas columns / rows must be odd!
;                                         E.g. struct of array has following structure for a 3x3 matrix:
;                                         $iMatrix = 3 * 3
;                                         $tStruct = DllStructCreate("float Matrix[" & $iMatrix & "]")
;                                         $tStruct.Matrix((1)) = 0.1
;                                         $tStruct.Matrix((2)) = 0.2
;                                         $tStruct.Matrix((3)) = 0.3
;                                         $tStruct.Matrix((4)) = 1.1
;                                         $tStruct.Matrix((5)) = 1.2
;                                         $tStruct.Matrix((6)) = 1.3
;                                         $tStruct.Matrix((7)) = 2.1
;                                         $tStruct.Matrix((8)) = 2.2
;                                         $tStruct.Matrix((9)) = 2.3
;                                         As an array:
;                                         [0.1, 0.1, 0.1]
;                                         [1.1, 1.1, 1.1]
;                                         [2.1, 2.1, 2.1]
;                  $iMatrix             - [optional] an integer value. Default is 0. The amount of matrix elements. E.g. a 3x3 matrix
;                                         has 9 elements.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Convolution($hImage, $fFactor, $fBias, $iMode = 1, $tMatrix = 0, $iMatrix = 0, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Convolution", "ptr", $hImage, "float", $fFactor, "float", $fBias, "byte", $iMode, "struct*", $tMatrix, "ushort", $iMatrix, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Convolution

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Raster
; Description ...: Creates a raster effect based on ellipses.
; Syntax ........: _GDIPlus_BitmapApplyFilter_Raster($hImage[, $iSizeW = 8[, $iSizeH = 8[, $fDensity = 0.0[, $fbrightness = 0[,
;                  $fBias = 0[, $iMode = 1[, $bGDI_Bmp = False]]]]]]])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $iSizeW              - [optional] an integer value. Default is 8. Width of the raster ellipse.
;                  $iSizeH              - [optional] an integer value. Default is 8. Height of the raster ellipse.
;                  $fDensity            - [optional] a floating point value. Default is 0.0. Represents the pixel density.
;                  $fbrightness         - [optional] a floating point value. Default is 0. Represents the brightness of the ellipse color.
;                  $fBias              - [optional] a floating point value. Default is 0. Adjusts the size of the ellipse.
;                  $iMode               - [optional] an integer value. Default is 1. 1 = colorized, >1 = b/w.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Raster($hImage, $iSizeW = 8, $iSizeH = 8, $fDensity = 0.0, $fbrightness = 10, $fBias = 0, $iMode = 1, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Raster", "ptr", $hImage, "uint", $iSizeW, "uint", $iSizeH, "float", $fDensity, "float", $fbrightness, "float", $fBias, "byte", $iMode, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Raster

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Pixelate
; Description ...: Pixelates an image.
; Syntax ........: _GDIPlus_BitmapApplyFilter_Pixelate($hImage[, $iPixelate = 8[, $bGDI_Bmp = False]])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $iPixelate           - [optional] an integer value. Default is 8. The divisor for the width / height of the image.
;                                         The higher the value the more pixelated will be the image.
;                  $bGrid               - [optional] a boolean value. Default is False. If true a grid will be drawn according to the pixel size.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Pixelate($hImage, $iPixelate = 8, $bGrid = False, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Pixelate", "ptr", $hImage, "byte", $iPixelate, "bool", $bGrid, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Pixelate

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Dilatation
; Description ...: Gradually enlarges the boundaries of regions of foreground pixels (i.e. white pixels, typically).
; Syntax ........: _GDIPlus_BitmapApplyFilter_Dilate($hImage[, $iSize = 5[, $bGDI_Bmp = False]])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $iSize               - [optional] an integer value. Default is 5. The higher the value the more time will
;                                         needed for calculation. $iSize is limited to a value between 2 and 32.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Dilatation($hImage, $iSize = 5, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Dilatation", "ptr", $hImage, "byte", $iSize, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Dilatation

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Erosion
; Description ...: Erodes away the boundaries of regions of foreground pixels (i.e. white pixels, typically).
; Syntax ........: _GDIPlus_BitmapApplyFilter_Erosion($hImage[, $iSize = 5[, $bGDI_Bmp = False]])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $iSize               - [optional] an integer value. Default is 5. The higher the value the more time will
;                                         needed for calculation. $iSize is limited to a value between 2 and 32.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Erosion($hImage, $iSize = 5, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Erosion", "ptr", $hImage, "byte", $iSize, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Erosion

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_OilPainting
; Description ...: Applies an oil painting look to the image.
; Syntax ........: _GDIPlus_BitmapApplyFilter_OilPainting($hImage, $iRadius, $fIntensityLevels[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $iRadius             - an integer value. The size of the brush. $iRadius is limited to a value between 1 and 32.
;                  $fIntensityLevels    - a floating point value. The higher the value the more details will be drawn and also
;                                         more time will needed for calculation. Lower values mean more solid colors.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_OilPainting($hImage, $iRadius, $fIntensityLevels, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_OilPainting", "ptr", $hImage, "byte", $iRadius, "float", $fIntensityLevels, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_OilPainting

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_ColorAccent
; Description ...: Make the image greyscale except the selected Hue value.
; Syntax ........: _GDIPlus_BitmapApplyFilter_ColorAccent($hImage[, $iHue = 0[, $fRange = 15[, $bGDI_Bmp = False]]])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $iHue                - [optional] an integer value. Default is 0°. A Hue value which will be skipped to be greyscale.
;                                         Range: 0° - 360°
;                  $fRange              - [optional] a floating point value. Default is 15. Range of Hue value.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........: http://www.rapidtables.com/convert/color/rgb-to-hsv.htm
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_ColorAccent($hImage, $iHue = 0, $fRange = 15, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_ColorAccent", "ptr", $hImage, "ushort", $iHue, "float", $fRange, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_ColorAccent

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_PenSketch
; Description ...: A bundle of several filters to produce a pen sketch effect.
; Syntax ........: _GDIPlus_BitmapApplyFilter_PenSketch($hImage, $iThreshold[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $iThreshold          - an integer value. This value is used for _GDIPlus_BitmapApplyFilter_Convolution (Sobel)
;                                         filter.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_PenSketch($hImage, $iThreshold, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_PenSketch", "ptr", $hImage, "float", $iThreshold, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_PenSketch

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_PenSketch2
; Description ...: A bundle of several filters to produce a pen sketch effect.
; Syntax ........: _GDIPlus_BitmapApplyFilter_PenSketch2($hImage, $iThreshold[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $iThreshold          - an integer value. This value is used for _GDIPlus_BitmapApplyFilter_Convolution (Sobel)
;                                         filter.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_PenSketch2($hImage, $iThreshold, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_PenSketch2", "ptr", $hImage, "ubyte", $iThreshold, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_PenSketch2

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Cartoon1
; Description ...: Creates a cartoon effect image.
; Syntax ........: _GDIPlus_BitmapApplyFilter_Cartoon1($hImage, $iRadius, $fIntensityLevels, $iThreshold[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $iRadius             - an integer value. The size of the brush. $iRadius is limited to a value between 1 and 32.
;                  $fIntensityLevels    - a floating point value. The higher the value the more details will be drawn and also
;                                         more time will needed for calculation. Lower values mean more solid colors.
;                  $iThreshold          - an integer value. The lower the value the more black contour lines will be drawn.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Cartoon1($hImage, $iRadius, $fIntensityLevels, $iThreshold, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Cartoon1", "ptr", $hImage, "ubyte", $iRadius, "float", $fIntensityLevels, "ubyte", $iThreshold, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Cartoon1

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_TiltShift
; Description ...: Creates a tilf shift effect.
; Syntax ........: _GDIPlus_BitmapApplyFilter_TiltShift($hImage, $fPosY[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $fPosY               - a floating point value. This value is the area in the image where no blurring occurs whereas
;                                         $fPosY is the start and $fPosY + $fPosY / 2 the end position.
;                  $iIntensity          - an integer value. The higher the value the more the image will be blurred.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_TiltShift($hImage, $fPosY, $iIntensity, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_TiltShift", "ptr", $hImage, "float", $fPosY, "uByte", $iIntensity, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_TiltShift

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_RadialBlur
; Description ...: Creates a radial blur effect.
; Syntax ........: _GDIPlus_BitmapApplyFilter_RadialBlur($hImage, $fPosX, $fPosY, $fRadius, $iIntensity[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $fPosX               - a floating point value. X position if the circle.
;                  $fPosY               - a floating point value. Y position if the circle.
;                  $fRadius             - a floating point value. Radius of the non blur circle.
;                  $iIntensity          - an integer value. The higher the value the more the image will be blurred.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_RadialBlur($hImage, $fPosX, $fPosY, $fRadius, $iIntensity, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_RadialBlur", "ptr", $hImage, "float", $fPosX, "float", $fPosY, "float", $fRadius, "uByte", $iIntensity, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_RadialBlur

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_TimeWarp
; Description ...: Creates a time warp effect.
; Syntax ........: _GDIPlus_BitmapApplyFilter_TimeWarp($hImage, $fFactor, $fMidX, $fMidY[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $fFactor             - a floating point value. The strength of the time warp effect
;                  $fMidX               - a floating point value. X coordinate for the center.
;                  $fMidY               - a floating point value. Y coordinate for the center.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_TimeWarp($hImage, $fFactor, $fMidX, $fMidY, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_TimeWarp", "ptr", $hImage, "float", $fFactor, "float", $fMidX, "float", $fMidY, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_TimeWarp

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_FishEye
; Description ...: Creates a fish eye effect.
; Syntax ........: _GDIPlus_BitmapApplyFilter_FishEye($hImage[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_FishEye($hImage, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_FishEye", "ptr", $hImage, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_FishEye

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Wave
; Description ...: Adds a wavy look to the image.
; Syntax ........: _GDIPlus_BitmapApplyFilter_Wave($hImage, $fAmplitudeX, $fAmplitudeY, $fFrequencyX, $fFrequencyY[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $fAmplitudeX         - a floating point value.
;                  $fAmplitudeY         - a floating point value.
;                  $fFrequencyX         - a floating point value.
;                  $fFrequencyY         - a floating point value.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Wave($hImage, $fAmplitudeX, $fAmplitudeY, $fFrequencyX, $fFrequencyY, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Wave", "ptr", $hImage, "float", $fAmplitudeX, "float", $fAmplitudeY, "float", $fFrequencyX, "float", $fFrequencyY, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Wave

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Swirl
; Description ...: Creates a swirl effect.
; Syntax ........: _GDIPlus_BitmapApplyFilter_Swirl($hImage, $fDegree[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $fDegree             - a floating point value.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Swirl($hImage, $fDegree, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Swirl", "ptr", $hImage, "float", $fDegree, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Swirl

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_XRay
; Description ...: Creates a x-ray effect.
; Syntax ........: _GDIPlus_BitmapApplyFilter_XRay($hImage, $iBias, $bInvert[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $iBias               - an integer value. The bias value increases / decreases the brightness of the image
;                  $bInvert             - a boolean value. Inverts the colors (negative).
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_XRay($hImage, $iBias, $bInvert, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_XRay", "ptr", $hImage, "byte", $iBias, "bool", $bInvert, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_XRay

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_DistortionBlur
; Description ...: Creates a blurred / distored image effect.
; Syntax ........: _GDIPlus_BitmapApplyFilter_DistortionBlur($hImage, $iDistortFactor[, $bGDI_Bmp = False])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $iDistortFactor      - an integer value. The higher the value the more the pixels will be distorted.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_DistortionBlur($hImage, $iDistortFactor, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_DistortionBlur", "ptr", $hImage, "ushort", $iDistortFactor, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_DistortionBlur

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_BWJJNDithering
; Description ...: Converts the image to a black and white image using Jarvis, Judice, and Ninke dithering
; Syntax ........: _GDIPlus_BitmapApplyFilter_BWJJNDithering($hImage[, $fErrorMultiplier = 0.3333333[, $iThreshold = 128[,
;                  $bGDI_Bmp = False]]])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $fErrorMultiplier    - [optional] a floating point value. Default is 0.3333333.
;                  $iThreshold          - [optional] an integer value. Default is 128. Level between black = 0 and white = 255.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_BWJJNDithering($hImage, $fErrorMultiplier = 0.3333333, $iThreshold = 128, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    $iThreshold = $iThreshold < 0 ? 0 : $iThreshold > 255 ? 255 : $iThreshold
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_BWJJNDithering", "ptr", $hImage, "float", $fErrorMultiplier, "ubyte", $iThreshold, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_BWJJNDithering

; #FUNCTION# ====================================================================================================================
; Name ..........: _GDIPlus_BitmapApplyFilter_Indexed
; Description ...: Converts the image to 1, 16 or 256 color bitmap. Dithering is optional.
; Syntax ........: _GDIPlus_BitmapApplyFilter_Indexed($hImage[, $iColors = 256[, $iDitherStrength = 5[, $iDitherMode = 1[,
;                  $bDither = True[, $bGDI_Bmp = False]]]]])
; Parameters ....: $hImage              - a handle to a GDIPlus bitmap.
;                  $iColors             - [optional] an integer value. Default is 256. 1, 16 or 256 color are implemented yet only.
;                  $iDitherMode         - [optional] an integer value. Default is 1. 2 is calculated with Euclidean distance.
;                  $bDither             - [optional] a boolean value. Default is True. If false the dithering is disabled.
;                  $bGDI_Bmp            - [optional] a boolean value. Default is False. If false a GDIPlus bitmap handle will be returned,
;                                         otherwise a GDI bitmap handle.
; Return values .: A bitmap handle (GDI/GDI+) depending on $bGDI_Bmp value.
; Author ........: UEZ
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GDIPlus_BitmapApplyFilter_Indexed($hImage, $iColors = 256, $iDitherMode = 1, $bDither = True, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Indexed", "ptr", $hImage, "ulong", $iColors, "bool", $bDither, "ubyte",  $iDitherMode, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc   ;==>_GDIPlus_BitmapApplyFilter_Indexed

Func _GDIPlus_BitmapApplyFilter_Mosaic($hImage, $iSites, $bOrdered, $bBorder, $iCalcMode, $iBorderColor, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Mosaic", "ptr", $hImage, "ULong", $iSites, "bool", $bOrdered, "bool", $bBorder, "ubyte", $iCalcMode, "ulong", $iBorderColor, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc

Func _GDIPlus_BitmapApplyFilter_Delaunay($hImage, $iBlur = 4, $fSobel = 1.0, $iThresholdBW = 60, $iSpaceX = 4, $iSpaceY = 4, $iBorderSpaceX = 16, $iBorderSpaceY = 16, _
                                                                  $bRndPoints = False, $iRndPoints = 0, $bShowEdges = False, $iAlpha = 0x60, $bWireframe = False, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Delaunay", "ptr", $hImage, "ubyte", $iBlur, "float", $fSobel, "ubyte", $iThresholdBW, "ulong", $iSpaceX, "ulong", $iSpaceY, "ubyte", _
                                                                            $iBorderSpaceX, "ubyte", $iBorderSpaceY, "bool", $bRndPoints, "ulong", $iRndPoints, "bool", $bShowEdges, "ubyte", $iAlpha, "bool", $bWireframe, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc

Func _GDIPlus_BitmapApplyFilter_Spiral($hImage, $iMode = 1, $iBgColor = 0xFFF0F0F0, $bGreyscale = True, $bGDI_Bmp = False)
    If Not IsPtr($hImage) Then Return SetError(1, 0, 0)
    Local Const $aReturn = DllCall($__hDLL__FX__, "ptr", "_GDIPlus_BitmapApplyFilter_Spiral", "ptr", $hImage, "ubyte", $iMode, "ulong", $iBgColor, "bool", $bGreyscale, "bool", $bGDI_Bmp)
    If Not $aReturn[0] Then Return SetError(2, 0, 0)
    Return $aReturn[0]
EndFunc

You need the DLL version dated to 2020-11-16 to use the UDF properly.

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

Im gonna ask off topic here, but i have an idea i need to ask it.

Is it possible do turn fonts to kernels and pass it through the image to enhance structures that is similar to the font on the image?

Would such an idea work in your opinion?

Link to comment
Share on other sites

2 hours ago, novel said:

Is it possible do turn fonts to kernels and pass it through the image to enhance structures that is similar to the font on the image?

Hmm, I don't know what you mean! :huh2: 

Any example?

😷

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

While i was digging a lot to learn about raster image filters, i have discovered in imagemagick library, they write a small script that we can transfer images to kernels, even though i didnt try it, it seems to work with perl which i have no experience at all.

There is an extensive explanation about morphologies and kernels in the link. 

https://legacy.imagemagick.org/Usage/morphology/#image2kernel

Script is here: https://legacy.imagemagick.org/Usage/scripts/image2kernel

Link to comment
Share on other sites

I was thinking to use this script (somehow) to transfer fonts to kernels to use them in convolution filters to enhance (increase brightness - sharpen) the fonts in the image so it will be the best preprocessing for OCR, ofc im just imagining.

That i was thinking to iterate all the font-kernels through the image to enhance the characters in the image.

Quote

 

 

 

The default for most morphology methods is a setting of 'None'. This means that after each kernel has been applied using the morphology method given, the resulting image should be used as the source for next kernel. That is simply 're-iterate' or reuse the resulting image from applying one kernel, for the next kernel.

Quote

 

For example, if I Convolve using 2, 90 degree rotated 'Blur' kernels we get the following.



  convert pixel.gif  -morphology Convolve "Blur:0x1>" \
          -auto-level  blur_re-iterate.gif
[IM Output] * [IM Output] , [IM Output] ==> [IM Output]

 

As you can see both kernels were applied to the image one after the other, so that each kernel works with the result of the previous kernel. That is it 're-iterates' the result of one kernel with the next kernel, in sequence.

 

Link to comment
Share on other sites

I don't know if this helps but you can use a manual kernel to pass it to the _GDIPlus_BitmapApplyFilter_Convolution function.

_GDIPlus_BitmapApplyFilter_Convolution_ManualMatrix.au3

#include "_GDIPlus_BitmapApplyFilter.au3"

Global Const $STM_SETIMAGE = 0x0172

Global Const $hDLL = _GDIPlus_BitmapApplyFilter_Open()

Global Const $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Face.png")
Global Const $iW = _GDIPlus_ImageGetWidth($hImage), $iH = _GDIPlus_ImageGetHeight($hImage)
Global Const $hGUI = GUICreate("", $iW * 2, $iH)
Global $fFactor = 1, $fBias = 0, $iMode = 0, $i
Local Const $iMatrix = 9 * 9
$tStruct = DllStructCreate("float Matrix[" & $iMatrix & "]")
;create motion blur
; 1 0 0 0 0 0 0 0 1
; 0 1 0 0 0 0 0 1 0
; 0 0 1 0 0 0 1 0 0
; 0 0 0 1 0 1 0 0 0
; 0 0 0 0 1 0 0 0 0
; 0 0 0 1 0 1 0 0 0
; 0 0 1 0 0 0 1 0 0
; 0 1 0 0 0 0 0 1 0
; 1 0 0 0 0 0 0 0 1



For $i = 0 to 8
    $tStruct.Matrix((9 + 8 * $i)) = 1 ;-100
    $tStruct.Matrix((1 + 10 * $i)) = 1 ;99
Next

;~ $tStruct.Matrix((41)) = 151

TrayTip("Information", "Please wait while calculating...", 60, 1)
Global $fEndtime, $fTimer = TimerInit()
Global Const $hGDI_new = _GDIPlus_BitmapApplyFilter_Convolution($hImage, $fFactor, $fBias, $iMode, $tStruct, $iMatrix, True)
$fEndtime = TimerDiff($fTimer)

Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW - 1, $iH - 1)
Global Const $iPic_o = GUICtrlCreatePic("", $iW, 0, $iW - 1, $iH - 1)
_WinAPI_DeleteObject(GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDI_new))
Global Const $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_WinAPI_DeleteObject(GUICtrlSendMsg($iPic_o, $STM_SETIMAGE, $IMAGE_BITMAP, $hGDIBitmap))

WinSetTitle($hGUI, "", "_GDIPlus_BitmapApplyFilter_Convolution / " & Round($fEndtime, 2) & " ms")
GUISetState()
TrayTip("Information", "Done in " & Round($fEndtime, 2) & " ms.", 10, 1)

Do
Until GUIGetMsg() = -3

_GDIPlus_ImageDispose($hImage)
_WinAPI_DeleteObject($hGDI_new)
_WinAPI_DeleteObject($hGDIBitmap)
_GDIPlus_Shutdown()
_GDIPlus_BitmapApplyFilter_Close()
GUIDelete($hGUI)

Maybe you to have to define the kernels (matrix) and pass each kernel to the image.

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

Link to comment
Share on other sites

  • UEZ changed the title to _GDIPlus_BitmapApplyFilter v0.9.8 build 2020-11-16 beta
  • 9 months later...
IMPORTANT: You are not allowed to sell this code or just parts of it in a commercial project

@UEZ Really?
Would need this in a project for my employer...
WinCC 7.5 Visu. Just wanna add a backdrop shadow to the existing picture.
So..
1. Screenshot of the given zone (Done)
2. Remove the background color and make it transparent. (Done)
3. Make everything that is left black.
4. Directional blur or just Gaussian blur and offset picture afterward to sim light direction.
5. Set global transparency to 10%
6. Save to png. (Done)

 

Edited by Blaxxun
Link to comment
Share on other sites

  • UEZ changed the title to _GDIPlus_BitmapApplyFilter v0.9.8 build 2024-04-17 beta

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