X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Fimage.hpp;h=7dd18c1225e821a0286ea11e0a73989be57acc51;hb=c3fe91d4c597da17e1eb9e75d36176465f44060a;hp=ea3eefb0d589c6e3f342860b8a1bd9720b3011bf;hpb=66dfdda1767b11e132c259adb6c1872dc2e1fff6;p=apitrace diff --git a/common/image.hpp b/common/image.hpp index ea3eefb..7dd18c1 100644 --- a/common/image.hpp +++ b/common/image.hpp @@ -78,7 +78,7 @@ public: } inline signed stride(void) const { - return flipped ? -width*channels : width*channels; + return flipped ? -(signed)(width*channels) : width*channels; } bool writeBMP(const char *filename) const; @@ -94,16 +94,21 @@ public: return true; } - bool writePNG(const char *filename) const; + bool + writePNG(std::ostream &os) const; + + inline bool + writePNG(const char *filename) const { + std::ofstream os(filename, std::ofstream::binary); + if (!os) { + return false; + } + return writePNG(os); + } double compare(Image &ref); }; -bool writePixelsToBuffer(unsigned char *pixels, - unsigned w, unsigned h, unsigned numChannels, - bool flipped, - char **buffer, - int *size); Image * readPNG(const char *filename); @@ -111,6 +116,7 @@ readPNG(const char *filename); const char * readPNMHeader(const char *buffer, size_t size, unsigned *channels, unsigned *width, unsigned *height); + } /* namespace image */