Add sfBuffer wrapper and implement sf::Image::saveToMemory#205
Add sfBuffer wrapper and implement sf::Image::saveToMemory#205eXpl0it3r merged 2 commits intoSFML:masterfrom
sfBuffer wrapper and implement sf::Image::saveToMemory#205Conversation
ChrisThrasher
left a comment
There was a problem hiding this comment.
I appreciate you putting this together with all the right docs and everything.
sfBuffer wrapper and implement sf::Image::saveToMemorysfBuffer wrapper and implement sf::Image::saveToMemory
11c69d7 to
855e1de
Compare
76afd71 to
8e0741b
Compare
8e0741b to
a529368
Compare
|
I used the following code to test the API. #include <SFML/Graphics.h>
#include <stdio.h>
int main(void)
{
const int WIDTH = 256;
sfImage* image = sfImage_createFromColor(WIDTH, 1, sfMagenta);
for (int x = 0; x < WIDTH; ++x)
sfImage_setPixel(image, x, 0, sfColor_fromRGB(x, 255, x));
sfBuffer* buffer = sfBuffer_create();
sfBool success = sfImage_saveToMemory(image, buffer, "png");
printf("Succes: %d\n", success);
sfImage_destroy(image);
FILE* f = fopen("out.png", "wb");
fwrite(sfBuffer_getData(buffer), 1, sfBuffer_getSize(buffer), f);
fclose(f);
sfBuffer_destroy(buffer);
return 0;
} |
|
@oprypin any comment from your side? 🙂 |
|
It's good. |
|
Hmmm I put it off as "we can always move it later", but then we'd be breaking code. While I don't really hold myself to the same non-breaking standard for CSFML as for SFML, I think it might after all be beneficial to reduce it where possible. So I think, it does after all matter and we should move |
|
There are no other |
|
Hm but wait, if |
|
But anyway probably |
It could, but I wouldn't want such a workaround, just to avoid some potential breaking code. No need to add technical debt. |
SFML/SFML#1669 Co-authored-by: Chris Thrasher <chrisjthrasher@gmail.com>
f759600 to
0a6b875
Compare
|
I moved sfBuffer into csfml-system. |
Alternative to #195 using a C wrapper over an
std::vector.