_GDIPlus_BitmapApplyFilter v0.9.7 build 2020-11-16 beta (Windows only)

User projects written in or related to FreeBASIC.
Post Reply
UEZ
Posts: 972
Joined: May 05, 2017 19:59
Location: Germany

_GDIPlus_BitmapApplyFilter v0.9.7 build 2020-11-16 beta (Windows only)

Post by UEZ »

I've written a DLL in FreeBasic to apply several filters to an image using GDIPlus.

Source code can be found here: https://pastebin.com/Lugp6rCR

Following functions have been implement so far:
  • _GDIPlus_BitmapApplyFilter_BWJJNDithering
  • _GDIPlus_BitmapApplyFilter_Cartoon1
  • _GDIPlus_BitmapApplyFilter_ColorAccent
  • _GDIPlus_BitmapApplyFilter_Convolution_AnotherBlur
  • _GDIPlus_BitmapApplyFilter_Convolution_BoxBlur
  • _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection1
  • _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection2
  • _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection3
  • _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection4
  • _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection5
  • _GDIPlus_BitmapApplyFilter_Convolution_EdgeDetection6
  • _GDIPlus_BitmapApplyFilter_Convolution_Emboss1
  • _GDIPlus_BitmapApplyFilter_Convolution_Emboss45Degree
  • _GDIPlus_BitmapApplyFilter_Convolution_EmbossTopLeftBottomRight
  • _GDIPlus_BitmapApplyFilter_Convolution_Gaussian3x3
  • _GDIPlus_BitmapApplyFilter_Convolution_Gaussian5x5_1
  • _GDIPlus_BitmapApplyFilter_Convolution_Gaussian5x5_2
  • _GDIPlus_BitmapApplyFilter_Convolution_GaussianBlur
  • _GDIPlus_BitmapApplyFilter_Convolution_IntenseEmboss
  • _GDIPlus_BitmapApplyFilter_Convolution_Kirsch
  • _GDIPlus_BitmapApplyFilter_Convolution_Laplace1
  • _GDIPlus_BitmapApplyFilter_Convolution_Laplace2
  • _GDIPlus_BitmapApplyFilter_Convolution_Laplace3
  • _GDIPlus_BitmapApplyFilter_Convolution_LaplacianOfGaussian
  • _GDIPlus_BitmapApplyFilter_Convolution_ManualMatrix
  • _GDIPlus_BitmapApplyFilter_Convolution_MotionBlur
  • _GDIPlus_BitmapApplyFilter_Convolution_Outline3x3
  • _GDIPlus_BitmapApplyFilter_Convolution_Prewitt
  • _GDIPlus_BitmapApplyFilter_Convolution_Sharpen1
  • _GDIPlus_BitmapApplyFilter_Convolution_Sharpen2
  • _GDIPlus_BitmapApplyFilter_Convolution_Sobel
  • _GDIPlus_BitmapApplyFilter_Convolution_SovelVsPrewitt
  • _GDIPlus_BitmapApplyFilter_Convolution_TriangleBlur
  • _GDIPlus_BitmapApplyFilter_Convolution_Unsharp
  • _GDIPlus_BitmapApplyFilter_Convolution_Unsharp5x5
  • _GDIPlus_BitmapApplyFilter_Delaunay
  • _GDIPlus_BitmapApplyFilter_Dilatation
  • _GDIPlus_BitmapApplyFilter_DistortionBlur
  • _GDIPlus_BitmapApplyFilter_Edges
  • _GDIPlus_BitmapApplyFilter_Erosion
  • _GDIPlus_BitmapApplyFilter_FishEye
  • _GDIPlus_BitmapApplyFilter_Indexed
  • _GDIPlus_BitmapApplyFilter_Jitter
  • _GDIPlus_BitmapApplyFilter_Kuwahara
  • _GDIPlus_BitmapApplyFilter_Linellism
  • _GDIPlus_BitmapApplyFilter_Median
  • _GDIPlus_BitmapApplyFilter_Median2
  • _GDIPlus_BitmapApplyFilter_OilPainting
  • _GDIPlus_BitmapApplyFilter_PenSketch
  • _GDIPlus_BitmapApplyFilter_PenSketch2
  • _GDIPlus_BitmapApplyFilter_Pixelate
  • _GDIPlus_BitmapApplyFilter_Pointillism
  • _GDIPlus_BitmapApplyFilter_RadialBlur
  • _GDIPlus_BitmapApplyFilter_Raster
  • _GDIPlus_BitmapApplyFilter_Swirl
  • _GDIPlus_BitmapApplyFilter_SymmetricNearestNeighbour
  • _GDIPlus_BitmapApplyFilter_TiltShift
  • _GDIPlus_BitmapApplyFilter_TimeWarp
  • _GDIPlus_BitmapApplyFilter_Wave
  • _GDIPlus_BitmapApplyFilter_XRay
_GDIPlus_BitmapApplyFilter.bi:

Code: Select all

#pragma Once
#Include "fbgfx.bi"

Extern "Windows-MS" Lib "_GDIPlus_BitmapApplyFilter"

'#Include Once "windows.bi"
#Ifdef __Fb_64bit__
    #Inclib "gdiplus"
    #Include Once "win/gdiplus-c.bi"
#Else
    #Include Once "win/gdiplus.bi"
    Using gdiplus
#Endif

Using FB

Enum Filters
		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
End Enum

Declare Function _GDIPlus_BitmapCreateBW(hImage As Any Ptr, iThreshold As UShort) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_SymmetricNearestNeighbour(ByVal hImage As Any Ptr, fRadius As Single, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Jitter(ByVal hImage As Any Ptr, iAmount As ULong, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Median(ByVal hImage As Any Ptr, fRadius As Single, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Kuwahara(ByVal hImage As Any Ptr, iSize As ULong, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Edges(ByVal hImage As Any Ptr, bMode As UByte, bInverse As Bool, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Pointillism(ByVal hImage As Any Ptr, iRounds As ULong, iSize As ULong, iA As UByte, bBorder As Bool, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Linellism(ByVal hImage As Any Ptr, iRounds As ULong, iSize As ULong, iA As UByte, iMode As UByte, bBorder As Bool, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Convolution(ByVal hImage As Any Ptr, fFactor As Single, fBias As Single, iMode As UByte, pMStruct As Any Ptr, iMatrix As UShort, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Raster(ByVal hImage As Any Ptr, iSizeW As ULong, iSizeH As ULong, fDensity As Single, fBrightness As Single, fBias As Single, iMode As Byte, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Rasterize(ByVal hImage As Any Ptr, iSpaceX As ULong, iSpaceY As ULong, iDelCol as Ulong, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Pixelate(ByVal hImage As Any Ptr, iPixelate As UByte, bGrid As Bool, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Dilatation(ByVal hImage As Any Ptr, Size As UByte, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Erosion(ByVal hImage As Any Ptr, Size As UByte, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_OilPainting(ByVal hImage As Any Ptr, iRadius As UByte, fIntensityLevels As Single, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_ColorAccent(ByVal hImage As Any Ptr, iHue As UShort, fRange As Single, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_PenSketch(ByVal hImage As Any Ptr, iThreshold As Single, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_PenSketch2(ByVal hImage As Any Ptr, iThreshold As UByte, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Cartoon1(ByVal hImage As Any Ptr, iRadius As UByte, fIntensityLevels As Single, iThreshold As UByte, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_TiltShift(ByVal hImage As Any Ptr, fPosY_Start As Single, iIntensity As UByte, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_RadialBlur(ByVal hImage As Any Ptr, fPosX As Single, fPosY As Single, fRadius As Single, iIntensity As UByte, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_TimeWarp(ByVal hImage As Any Ptr, fFactor As Single, fMidX As Single, fMidY As Single, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_FishEye(ByVal hImage As Any Ptr, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Wave(ByVal hImage As Any Ptr, fAmplitudeX As Single, fAmplitudeY As Single, fFrequencyX As Single, fFrequencyY As Single, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Swirl(ByVal hImage As Any Ptr, fDegree As Single, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_XRay(ByVal hImage As Any Ptr, iBias As Byte, bInvert As Bool, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Median2(ByVal hImage As Any Ptr, fRadius As Single, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_BWJJNDithering(ByVal hImage As Any Ptr, fErrorMultiplier As Single, iThreshold As UByte, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Indexed(ByVal hImage As Any Ptr, iColors As ULong, bDither As Bool, iDitherType As UByte, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Mosaic(ByVal hImage As Any Ptr, iSites As ULong, bOrdered As Bool, bBorder As Bool, iCalcMode As UByte, iBorderColor As UInteger, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_WaterDropGlassPane(ByVal hImage As Any Ptr, iPosX As UShort, iPosY As UShort, iAmount As UShort, iSizeMin As UByte, iSizeMax As UShort, iBlur As UByte, bGDI As Bool) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Blur(ByVal hImage As Any Ptr, iRadius As UByte) As Any Ptr
Declare Function _GDIPlus_BitmapApplyFilter_Delaunay(ByVal hImage As Any Ptr, iBlur as Ubyte, fSobel As single, iBW as Ubyte, iSpaceX as Ulong, iSpaceY as Ulong, iBorderSpaceX as Ubyte, iBorderSpaceY as Ubyte, bShowEdges As Bool, bGDI As Bool) As Any Ptr

End Extern



Screenshots and examples in AutoIt using the DLL can be found here: https://www.autoitscript.com/forum/file ... -udf-beta/


Or download some FreeBasic examples here: http://www.mediafire.com/file/7y07a02ep ... 16.7z/file


The gdiplus.bi lib seems to be messed up. I hope it will be fixed in the next release. :)


As I'm new to FB the code might be "unprofessional"...
Last edited by UEZ on Nov 18, 2020 21:27, edited 7 times in total.
UEZ
Posts: 972
Joined: May 05, 2017 19:59
Location: Germany

Re: _GDIPlus_BitmapApplyFilter v0.9.6 build 2017-05-14 beta

Post by UEZ »

Added a DL link to some FreeBasic examples -> see post #1.
Post Reply