mirror of
https://github.com/SFML/CSFML.git
synced 2026-10-28 13:46:13 +01:00
Implement sf::Image::saveToMemory
https://github.com/SFML/SFML/pull/1669 Co-authored-by: Chris Thrasher <chrisjthrasher@gmail.com>
This commit is contained in:
1 parent
39dd578d45
commit
725811baa9
2 files changed
+32
No files matched your search
@@ -32,6 +32,7 @@
|
|||||||
#include <SFML/Graphics/Color.h>
|
#include <SFML/Graphics/Color.h>
|
||||||
#include <SFML/Graphics/Rect.h>
|
#include <SFML/Graphics/Rect.h>
|
||||||
#include <SFML/Graphics/Types.h>
|
#include <SFML/Graphics/Types.h>
|
||||||
|
#include <SFML/System/Buffer.h>
|
||||||
#include <SFML/System/InputStream.h>
|
#include <SFML/System/InputStream.h>
|
||||||
#include <SFML/System/Vector2.h>
|
#include <SFML/System/Vector2.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@@ -156,9 +157,30 @@ CSFML_GRAPHICS_API void sfImage_destroy(sfImage* image);
|
|||||||
///
|
///
|
||||||
/// \return sfTrue if saving was successful
|
/// \return sfTrue if saving was successful
|
||||||
///
|
///
|
||||||
|
/// \see sfImage_saveToMemory
|
||||||
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
CSFML_GRAPHICS_API sfBool sfImage_saveToFile(const sfImage* image, const char* filename);
|
CSFML_GRAPHICS_API sfBool sfImage_saveToFile(const sfImage* image, const char* filename);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
/// \brief Save the image to a buffer in memory
|
||||||
|
///
|
||||||
|
/// The format of the image must be specified.
|
||||||
|
/// The supported image formats are bmp, png, tga and jpg.
|
||||||
|
/// This function fails if the image is empty, or if
|
||||||
|
/// the format was invalid.
|
||||||
|
///
|
||||||
|
/// \param image Image object
|
||||||
|
/// \param output Buffer to fill with encoded data
|
||||||
|
/// \param format Encoding format to use
|
||||||
|
///
|
||||||
|
/// \return sfTrue if saving was successful
|
||||||
|
///
|
||||||
|
/// \see sfImage_saveToFile
|
||||||
|
///
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
CSFML_GRAPHICS_API sfBool sfImage_saveToMemory(const sfImage* image, sfBuffer* output, const char* format);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
/// \brief Return the size of an image
|
/// \brief Return the size of an image
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -27,9 +27,11 @@
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
#include <SFML/Graphics/Image.h>
|
#include <SFML/Graphics/Image.h>
|
||||||
#include <SFML/Graphics/ImageStruct.h>
|
#include <SFML/Graphics/ImageStruct.h>
|
||||||
|
#include <SFML/System/BufferStruct.h>
|
||||||
#include <SFML/Internal.h>
|
#include <SFML/Internal.h>
|
||||||
#include <SFML/CallbackStream.h>
|
#include <SFML/CallbackStream.h>
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
sfImage* sfImage_create(unsigned int width, unsigned int height)
|
sfImage* sfImage_create(unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
@@ -131,6 +133,14 @@ sfBool sfImage_saveToFile(const sfImage* image, const char* filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
sfBool sfImage_saveToMemory(const sfImage* image, sfBuffer* output, const char* format)
|
||||||
|
{
|
||||||
|
CSFML_CHECK_RETURN(output, sfFalse);
|
||||||
|
CSFML_CALL_RETURN(image, saveToMemory(output->buffer, format), sfFalse);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void sfImage_createMaskFromColor(sfImage* image, sfColor colorKey, sfUint8 alpha)
|
void sfImage_createMaskFromColor(sfImage* image, sfColor colorKey, sfUint8 alpha)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user