X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=image.hpp;h=dc53ec990ee3a19f931f5e9160269c7e0c875169;hb=1c35c914cf934c957664d9692a099634aacc4e44;hp=e02abed08d6d667e54263734f274f7793a8d96bd;hpb=c4c0be53e8151a61529822c1c11a99fad3f6ec20;p=apitrace diff --git a/image.hpp b/image.hpp index e02abed..dc53ec9 100644 --- a/image.hpp +++ b/image.hpp @@ -65,15 +65,35 @@ public: return flipped ? pixels + (height - 1)*width*channels : pixels; } + inline const unsigned char *start(void) const { + return flipped ? pixels + (height - 1)*width*channels : pixels; + } + inline unsigned char *end(void) { return flipped ? pixels - width*channels : pixels + height*width*channels; } + inline const unsigned char *end(void) const { + return flipped ? pixels - width*channels : pixels + height*width*channels; + } + inline signed stride(void) const { return flipped ? -width*channels : width*channels; } bool writeBMP(const char *filename) const; + + void writePNM(std::ostream &os, const char *comment = NULL) const; + + inline bool writePNM(const char *filename, const char *comment = NULL) const { + std::ofstream os(filename, std::ofstream::binary); + if (!os) { + return false; + } + writePNM(os, comment); + return true; + } + bool writePNG(const char *filename) const; double compare(Image &ref);