From 317440bafe750383339d89cc8de53a2d36e0c8bf Mon Sep 17 00:00:00 2001 From: zii-dmg Date: Tue, 25 May 2021 12:55:01 +0300 Subject: [PATCH] Add Cairo.Surface.DeviceScale property (#251) --- Source/Libs/CairoSharp/NativeMethods.cs | 9 +++++++++ Source/Libs/CairoSharp/Surface.cs | 14 ++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Source/Libs/CairoSharp/NativeMethods.cs b/Source/Libs/CairoSharp/NativeMethods.cs index a77ba9b8a..4f2f02224 100644 --- a/Source/Libs/CairoSharp/NativeMethods.cs +++ b/Source/Libs/CairoSharp/NativeMethods.cs @@ -1027,6 +1027,10 @@ namespace Cairo internal delegate void d_cairo_surface_get_device_offset(IntPtr surface, out double x, out double y); internal static d_cairo_surface_get_device_offset cairo_surface_get_device_offset = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.Cairo), "cairo_surface_get_device_offset")); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void d_cairo_surface_get_device_scale(IntPtr surface, out double x, out double y); + internal static d_cairo_surface_get_device_scale cairo_surface_get_device_scale = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.Cairo), "cairo_surface_get_device_scale")); + //[DllImport (cairo, CallingConvention=CallingConvention.Cdecl)] //internal static extern void cairo_surface_get_fallback_resolution (IntPtr surface, out double x_pixels_per_inch, out double y_pixels_per_inch); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] @@ -1065,6 +1069,11 @@ namespace Cairo [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void d_cairo_surface_set_device_offset(IntPtr surface, double x, double y); internal static d_cairo_surface_set_device_offset cairo_surface_set_device_offset = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.Cairo), "cairo_surface_set_device_offset")); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void d_cairo_surface_set_device_scale(IntPtr surface, double x, double y); + internal static d_cairo_surface_set_device_scale cairo_surface_set_device_scale = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.Cairo), "cairo_surface_set_device_scale")); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void d_cairo_surface_set_fallback_resolution(IntPtr surface, double x, double y); internal static d_cairo_surface_set_fallback_resolution cairo_surface_set_fallback_resolution = FuncLoader.LoadFunction(FuncLoader.GetProcAddress(GLibrary.Load(Library.Cairo), "cairo_surface_set_fallback_resolution")); diff --git a/Source/Libs/CairoSharp/Surface.cs b/Source/Libs/CairoSharp/Surface.cs index 959230327..cd2bae8c8 100644 --- a/Source/Libs/CairoSharp/Surface.cs +++ b/Source/Libs/CairoSharp/Surface.cs @@ -205,6 +205,20 @@ namespace Cairo { } } + public PointD DeviceScale { + get { + CheckDisposed (); + double x, y; + NativeMethods.cairo_surface_get_device_scale (handle, out x, out y); + return new PointD(x, y); + } + + set { + CheckDisposed (); + NativeMethods.cairo_surface_set_device_scale (handle, value.X, value.Y); + } + } + [Obsolete ("Use Dispose()")] public void Destroy() {