From ad8a1aade0d60cf946e6eefd9a2206dbf73038ef Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Sat, 31 Mar 2012 22:45:37 +0200 Subject: [PATCH] Replaced getWidth/getHeight with getSize in sfImage and sfTexture --- include/SFML/Graphics/Image.h | 17 ++++------------- include/SFML/Graphics/Texture.h | 17 ++++------------- src/SFML/Graphics/Image.cpp | 15 ++++++++------- src/SFML/Graphics/Texture.cpp | 15 ++++++++------- 4 files changed, 24 insertions(+), 40 deletions(-) diff --git a/include/SFML/Graphics/Image.h b/include/SFML/Graphics/Image.h index 03f3782..5cead5f 100644 --- a/include/SFML/Graphics/Image.h +++ b/include/SFML/Graphics/Image.h @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -159,24 +160,14 @@ CSFML_GRAPHICS_API void sfImage_destroy(sfImage* image); CSFML_GRAPHICS_API sfBool sfImage_saveToFile(const sfImage* image, const char* filename); //////////////////////////////////////////////////////////// -/// \brief Return the width of an image +/// \brief Return the size of an image /// /// \param image Image object /// -/// \return Width in pixels +/// \return Size in pixels /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API unsigned int sfImage_getWidth(const sfImage* image); - -//////////////////////////////////////////////////////////// -/// \brief Return the height of an image -/// -/// \param image Image object -/// -/// \return Height in pixels -/// -//////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API unsigned int sfImage_getHeight(const sfImage* image); +CSFML_GRAPHICS_API sfVector2u sfImage_getSize(const sfImage* image); //////////////////////////////////////////////////////////// /// \brief Create a transparency mask from a specified color-key diff --git a/include/SFML/Graphics/Texture.h b/include/SFML/Graphics/Texture.h index ffe32d4..a1edce9 100644 --- a/include/SFML/Graphics/Texture.h +++ b/include/SFML/Graphics/Texture.h @@ -33,6 +33,7 @@ #include #include #include +#include #include @@ -111,24 +112,14 @@ CSFML_GRAPHICS_API sfTexture* sfTexture_copy(sfTexture* texture); CSFML_GRAPHICS_API void sfTexture_destroy(sfTexture* texture); //////////////////////////////////////////////////////////// -/// \brief Return the width of the texture +/// \brief Return the size of the texture /// /// \param texture Texture to read /// -/// \return Width in pixels +/// \return Size in pixels /// //////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API unsigned int sfTexture_getWidth(const sfTexture* texture); - -//////////////////////////////////////////////////////////// -/// \brief Return the height of the texture -/// -/// \param texture Texture to read -/// -/// \return Height in pixels -/// -//////////////////////////////////////////////////////////// -CSFML_GRAPHICS_API unsigned int sfTexture_getHeight(const sfTexture* texture); +CSFML_GRAPHICS_API sfVector2u sfTexture_getSize(const sfTexture* texture); //////////////////////////////////////////////////////////// /// \brief Copy a texture's pixels to an image diff --git a/src/SFML/Graphics/Image.cpp b/src/SFML/Graphics/Image.cpp index 01205e2..e424864 100644 --- a/src/SFML/Graphics/Image.cpp +++ b/src/SFML/Graphics/Image.cpp @@ -174,16 +174,17 @@ const sfUint8* sfImage_getPixelsPtr(const sfImage* image) //////////////////////////////////////////////////////////// -unsigned int sfImage_getWidth(const sfImage* image) +sfVector2u sfImage_getSize(const sfImage* image) { - CSFML_CALL_RETURN(image, getWidth(), 0); -} + sfVector2u size = {0, 0}; + CSFML_CHECK_RETURN(image, size); + sf::Vector2u sfmlSize = image->This.getSize(); -//////////////////////////////////////////////////////////// -unsigned int sfImage_getHeight(const sfImage* image) -{ - CSFML_CALL_RETURN(image, getHeight(), 0); + size.x = sfmlSize.x; + size.y = sfmlSize.y; + + return size; } diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index f411ba3..614c2df 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -147,16 +147,17 @@ void sfTexture_destroy(sfTexture* texture) //////////////////////////////////////////////////////////// -unsigned int sfTexture_getWidth(const sfTexture* texture) +sfVector2u sfTexture_getSize(const sfTexture* texture) { - CSFML_CALL_PTR_RETURN(texture, getWidth(), 0); -} + sfVector2u size = {0, 0}; + CSFML_CHECK_RETURN(texture, size); + sf::Vector2u sfmlSize = texture->This->getSize(); -//////////////////////////////////////////////////////////// -unsigned int sfTexture_getHeight(const sfTexture* texture) -{ - CSFML_CALL_PTR_RETURN(texture, getHeight(), 0); + size.x = sfmlSize.x; + size.y = sfmlSize.y; + + return size; }