From 09979569bbc8b197e93d13f321fa841bb4e77af4 Mon Sep 17 00:00:00 2001 From: JupiterRider <60042618+JupiterRider@users.noreply.github.com> Date: Fri, 6 Dec 2024 18:59:50 +0100 Subject: [PATCH] ImageKernelConvolution added --- Raylib-cs/interop/Raylib.cs | 4 ++++ Raylib-cs/types/Raylib.Utils.cs | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/Raylib-cs/interop/Raylib.cs b/Raylib-cs/interop/Raylib.cs index 9bb32fd..b93a37a 100644 --- a/Raylib-cs/interop/Raylib.cs +++ b/Raylib-cs/interop/Raylib.cs @@ -1568,6 +1568,10 @@ public static unsafe partial class Raylib [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void ImageBlurGaussian(Image* image, int blurSize); + // Apply custom square convolution kernel to image + [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern void ImageKernelConvolution(Image* image, float* kernel, int kernelSize); + /// Resize image (Bicubic scaling algorithm) [DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)] public static extern void ImageResize(Image* image, int newWidth, int newHeight); diff --git a/Raylib-cs/types/Raylib.Utils.cs b/Raylib-cs/types/Raylib.Utils.cs index 5220316..97608ab 100644 --- a/Raylib-cs/types/Raylib.Utils.cs +++ b/Raylib-cs/types/Raylib.Utils.cs @@ -507,6 +507,18 @@ public static unsafe partial class Raylib } } + // Apply custom square convolution kernel to image + public static void ImageKernelConvolution(ref Image image, float[] kernel) + { + fixed (Image* imagePtr = &image) + { + fixed (float* kernelPtr = kernel) + { + ImageKernelConvolution(imagePtr, kernelPtr, kernel.Length); + } + } + } + /// Crop an image to a defined rectangle public static void ImageCrop(ref Image image, Rectangle crop) {