Skip to content

Commit c9b2c63

Browse files
committed
Add missing Resize method to the texture
1 parent 2361a83 commit c9b2c63

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/SFML.Graphics/Texture.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,15 @@ public Texture(Texture copy) :
255255
////////////////////////////////////////////////////////////
256256
public Image CopyToImage() => new Image(sfTexture_copyToImage(CPointer));
257257

258+
////////////////////////////////////////////////////////////
259+
/// <summary>
260+
/// Resize the texture.
261+
/// </summary>
262+
/// <param name="size">Width and height of the texture</param>
263+
/// <param name="srgb">True to enable sRGB conversion, false to disable it</param>
264+
////////////////////////////////////////////////////////////
265+
public bool Resize(Vector2u size, bool srgb = false) => srgb ? sfTexture_resizeSrgb(CPointer, size) : sfTexture_resize(CPointer, size);
266+
258267
////////////////////////////////////////////////////////////
259268
/// <summary>
260269
/// Update a texture from an array of pixels
@@ -346,7 +355,7 @@ public void Update(byte[] pixels, Vector2u size, Vector2u dest)
346355
/// <summary>
347356
/// Generate a mipmap using the current texture data
348357
/// </summary>
349-
///
358+
///
350359
/// <remarks>
351360
/// <para>Mipmaps are pre-computed chains of optimized textures. Each
352361
/// level of texture in a mipmap is generated by halving each of
@@ -365,7 +374,7 @@ public void Update(byte[] pixels, Vector2u size, Vector2u dest)
365374
/// modified, at which point this function will have to be called again to
366375
/// regenerate it.</para>
367376
/// </remarks>
368-
///
377+
///
369378
/// <returns>True if mipmap generation was successful, false if unsuccessful</returns>
370379
////////////////////////////////////////////////////////////
371380
public bool GenerateMipmap() => sfTexture_generateMipmap(CPointer);
@@ -393,7 +402,7 @@ public bool Smooth
393402
/// <summary>
394403
/// Enable or disable conversion from sRGB
395404
/// </summary>
396-
///
405+
///
397406
/// <remarks>
398407
/// <para>When providing texture data from an image file or memory, it can
399408
/// either be stored in a linear color space or an sRGB color space.
@@ -538,6 +547,12 @@ protected override void Destroy(bool disposing)
538547
[DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
539548
private static extern void sfTexture_destroy(IntPtr texture);
540549

550+
[DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
551+
private static extern bool sfTexture_resize(IntPtr texture, Vector2u size);
552+
553+
[DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
554+
private static extern bool sfTexture_resizeSrgb(IntPtr texture, Vector2u size);
555+
541556
[DllImport(CSFML.Graphics, CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity]
542557
private static extern Vector2u sfTexture_getSize(IntPtr texture);
543558

0 commit comments

Comments
 (0)