Added Image::UpdatePixels to CSFML and SFML.Net
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1436 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
e394b6f35c
commit
f9680f1818
@ -155,7 +155,6 @@ CSFML_API sfBool sfImage_CopyScreen(sfImage* image, sfRenderWindow* window, sfIn
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Change the color of a pixel of an image
|
/// Change the color of a pixel of an image
|
||||||
/// Don't forget to call Update when you end modifying pixels
|
|
||||||
///
|
///
|
||||||
/// \param image : Image to modify
|
/// \param image : Image to modify
|
||||||
/// \param x : X coordinate of pixel in the image
|
/// \param x : X coordinate of pixel in the image
|
||||||
@ -189,6 +188,21 @@ CSFML_API sfColor sfImage_GetPixel(const sfImage* image, unsigned int x, unsigne
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_API const sfUint8* sfImage_GetPixelsPtr(const sfImage* image);
|
CSFML_API const sfUint8* sfImage_GetPixelsPtr(const sfImage* image);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// Update a sub-rectangle of the image from an array of pixels
|
||||||
|
///
|
||||||
|
/// Warning: for performances reasons, this function doesn't
|
||||||
|
/// perform any check; thus you're responsible of ensuring that
|
||||||
|
/// \a rectangle does not exceed the image size, and that
|
||||||
|
/// \a pixels contains enough elements.
|
||||||
|
///
|
||||||
|
/// \param image : Image to update
|
||||||
|
/// \param rectangle : Sub-rectangle of the image to update
|
||||||
|
/// \param pixels : Array of pixels to write to the image
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
CSFML_API void sfImage_UpdatePixels(const sfImage* image, const sfUint8* pixels, sfIntRect rectangle);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Bind the image for rendering
|
/// Bind the image for rendering
|
||||||
///
|
///
|
||||||
|
@ -208,6 +208,16 @@ const sfUint8* sfImage_GetPixelsPtr(const sfImage* image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// Update a sub-rectangle of the image from an array of pixels
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
void sfImage_UpdatePixels(const sfImage* image, const sfUint8* pixels, sfIntRect rectangle)
|
||||||
|
{
|
||||||
|
sf::IntRect rect(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom);
|
||||||
|
CSFML_CALL_PTR(image, UpdatePixels(pixels, rect));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// Bind the image for rendering
|
/// Bind the image for rendering
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
@ -26,6 +26,7 @@ EXPORTS
|
|||||||
sfImage_SetPixel
|
sfImage_SetPixel
|
||||||
sfImage_GetPixel
|
sfImage_GetPixel
|
||||||
sfImage_GetPixelsPtr
|
sfImage_GetPixelsPtr
|
||||||
|
sfImage_UpdatePixels
|
||||||
sfImage_Bind
|
sfImage_Bind
|
||||||
sfImage_SetSmooth
|
sfImage_SetSmooth
|
||||||
sfImage_GetWidth
|
sfImage_GetWidth
|
||||||
|
@ -26,6 +26,7 @@ EXPORTS
|
|||||||
sfImage_SetPixel
|
sfImage_SetPixel
|
||||||
sfImage_GetPixel
|
sfImage_GetPixel
|
||||||
sfImage_GetPixelsPtr
|
sfImage_GetPixelsPtr
|
||||||
|
sfImage_UpdatePixels
|
||||||
sfImage_Bind
|
sfImage_Bind
|
||||||
sfImage_SetSmooth
|
sfImage_SetSmooth
|
||||||
sfImage_GetWidth
|
sfImage_GetWidth
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -267,6 +267,38 @@ namespace SFML
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// <summary>
|
||||||
|
/// Update the pixels of the image
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pixels">2 dimensions array containing the pixels</param>
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
public void UpdatePixels(Color[,] pixels)
|
||||||
|
{
|
||||||
|
UpdatePixels(pixels, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// <summary>
|
||||||
|
/// Update the pixels of the image
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pixels">2 dimensions array containing the pixels</param>
|
||||||
|
/// <param name="x">X position of the rectangle to update</param>
|
||||||
|
/// <param name="y">Y position of the rectangle to update</param>
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
public void UpdatePixels(Color[,] pixels, uint x, uint y)
|
||||||
|
{
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
fixed (Color* PixelsPtr = pixels)
|
||||||
|
{
|
||||||
|
int Width = pixels.GetLength(0);
|
||||||
|
int Height = pixels.GetLength(1);
|
||||||
|
sfImage_UpdatePixels(This, PixelsPtr, new IntRect((int)x, (int)y, Width, Height));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Bind the image for rendering
|
/// Bind the image for rendering
|
||||||
@ -393,6 +425,9 @@ namespace SFML
|
|||||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||||
static extern IntPtr sfImage_GetPixelsPtr(IntPtr This);
|
static extern IntPtr sfImage_GetPixelsPtr(IntPtr This);
|
||||||
|
|
||||||
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||||
|
unsafe static extern void sfImage_UpdatePixels(IntPtr This, Color* Pixels, IntRect Rectangle);
|
||||||
|
|
||||||
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
[DllImport("csfml-graphics"), SuppressUnmanagedCodeSecurity]
|
||||||
static extern void sfImage_Bind(IntPtr This);
|
static extern void sfImage_Bind(IntPtr This);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user