diff options
author | don bright <hugh.m.bright@gmail.com> | 2013-01-26 00:36:55 (GMT) |
---|---|---|
committer | don bright <hugh.m.bright@gmail.com> | 2013-01-26 00:36:55 (GMT) |
commit | c116a0849c7531ec4d0e59b6d61aaf6137dcd568 (patch) | |
tree | 39a8de4972d00aff8baaa05a51fda66d75fc6cdb /src/imageutils-lodepng.cc | |
parent | e80d847e3d9249d22bf70f257df7b2130487b211 (diff) |
undo experiment with object orientation
Diffstat (limited to 'src/imageutils-lodepng.cc')
-rw-r--r-- | src/imageutils-lodepng.cc | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/src/imageutils-lodepng.cc b/src/imageutils-lodepng.cc index a74f107..96d9d90 100644 --- a/src/imageutils-lodepng.cc +++ b/src/imageutils-lodepng.cc @@ -1,35 +1,16 @@ +#include "imageutils.h" #include "lodepng.h" #include <stdio.h> #include <stdlib.h> bool write_png(std::ostream &output, unsigned char *pixels, int width, int height) { - size_t dataout_size = -1; - unsigned char *dataout = (unsigned char *)malloc(width*height*4); - LodePNG_encode(&dataout, &dataout_size, pixels, width, height, LCT_RGBA, 8); - output.write( dataout, dataout_size );; - free( dataout ); - return true; -} - -bool write_png(const char *filename, unsigned char *pixels, int width, int height) -{ //encoder.settings.zlibsettings.windowSize = 2048; //LodePNG_Text_add(&encoder.infoPng.text, "Comment", "Created with LodePNG"); - size_t dataout_size = -1; unsigned char *dataout = (unsigned char *)malloc(width*height*4); LodePNG_encode(&dataout, &dataout_size, pixels, width, height, LCT_RGBA, 8); - //LodePNG_saveFile(dataout, dataout_size, "blah2.png"); - - FILE *f = fopen(filename, "wb"); - if (!f) { - free(dataout); - return false; - } - - fwrite(dataout, 1, dataout_size, f); - fclose(f); - free(dataout); + output.write( reinterpret_cast<const char*>(dataout), dataout_size );; + free( dataout ); return true; } |