FS#133 - Add a function to make fast updates of an image's pixels from an external source

Removed sf::Image constructors that called CreateXxx or LoadXxx (there was no way to check errors)


git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1307 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2009-12-05 11:35:27 +00:00
parent aff5c1a47c
commit fb7470cbc3
2 changed files with 65 additions and 56 deletions

View file

@ -62,26 +62,6 @@ public :
////////////////////////////////////////////////////////////
Image(const Image& copy);
////////////////////////////////////////////////////////////
/// Construct an empty image
///
/// \param width : Image width
/// \param height : Image height
/// \param color : Image color
///
////////////////////////////////////////////////////////////
Image(unsigned int width, unsigned int height, const Color& color = Color(0, 0, 0));
////////////////////////////////////////////////////////////
/// Construct the image from pixels in memory
///
/// \param width : Image width
/// \param height : Image height
/// \param pixels : Pointer to the pixels in memory (assumed format is RGBA)
///
////////////////////////////////////////////////////////////
Image(unsigned int width, unsigned int height, const Uint8* pixels);
////////////////////////////////////////////////////////////
/// Destructor
///
@ -209,6 +189,28 @@ public :
////////////////////////////////////////////////////////////
const Uint8* GetPixelsPtr() const;
////////////////////////////////////////////////////////////
/// Update the whole image from an array of pixels
///
/// \param pixels : Array of pixels to write to the image
///
////////////////////////////////////////////////////////////
void UpdatePixels(const Uint8* pixels);
////////////////////////////////////////////////////////////
/// 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 contain enough elements.
///
/// \param rectangle : Sub-rectangle of the image to update
/// \param pixels : Array of pixels to write to the image
///
////////////////////////////////////////////////////////////
void UpdatePixels(const Uint8* pixels, const IntRect& rectangle);
////////////////////////////////////////////////////////////
/// Bind the image for rendering
///
@ -302,12 +304,14 @@ private :
////////////////////////////////////////////////////////////
/// Make sure the texture in video memory is updated with the
/// array of pixels
///
////////////////////////////////////////////////////////////
void EnsureTextureUpdate();
////////////////////////////////////////////////////////////
/// Make sure the array of pixels is updated with the
/// texture in video memory
///
////////////////////////////////////////////////////////////
void EnsureArrayUpdate();