From 63aeac09cacac205dece5dc2646635fbd8a097f0 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Sat, 18 Nov 2017 20:50:56 -0500 Subject: [PATCH] SDL_image 2.0.2 --- src/SDL2.cs | 12 ++++++++++-- src/SDL2_image.cs | 28 +++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/SDL2.cs b/src/SDL2.cs index 541fa2d..a5f749c 100644 --- a/src/SDL2.cs +++ b/src/SDL2.cs @@ -137,9 +137,17 @@ namespace SDL2 * functions marked with the phrase "THIS IS A PUBLIC RWops FUNCTION!" */ - /* IntPtr refers to an SDL_RWops* */ + /* mem refers to a void*, IntPtr to an SDL_RWops* */ [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr SDL_RWFromMem(byte[] mem, int size); + public static extern IntPtr SDL_RWFromMem(IntPtr mem, int size); + + /* context refers to an SDL_RWops* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + internal static extern long SDL_RWtell(IntPtr context); + + /* context refers to an SDL_RWops* */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + internal static extern int SDL_RWclose(IntPtr context); #endregion diff --git a/src/SDL2_image.cs b/src/SDL2_image.cs index 61c2f53..a3423c9 100644 --- a/src/SDL2_image.cs +++ b/src/SDL2_image.cs @@ -50,7 +50,7 @@ namespace SDL2 */ public const int SDL_IMAGE_MAJOR_VERSION = 2; public const int SDL_IMAGE_MINOR_VERSION = 0; - public const int SDL_IMAGE_PATCHLEVEL = 0; + public const int SDL_IMAGE_PATCHLEVEL = 2; [Flags] public enum IMG_InitFlags @@ -212,6 +212,32 @@ namespace SDL2 int freedst ); + /* surface refers to an SDL_Surface* */ + [DllImport(nativeLibName, EntryPoint = "IMG_SaveJPG", CallingConvention = CallingConvention.Cdecl)] + private static extern int INTERNAL_IMG_SaveJPG( + IntPtr surface, + byte[] file, + int quality + ); + public static int IMG_SaveJPG(IntPtr surface, string file, int quality) + { + return INTERNAL_IMG_SaveJPG( + surface, + SDL.UTF8_ToNative(file), + quality + ); + } + + /* surface refers to an SDL_Surface*, dst to an SDL_RWops* */ + /* THIS IS A PUBLIC RWops FUNCTION! */ + [DllImport(nativeLibName, CallingConvention = CallingConvention.Cdecl)] + public static extern int IMG_SaveJPG_RW( + IntPtr surface, + IntPtr dst, + int freedst, + int quality + ); + #endregion } }