X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=image%2Fimage_raw.cpp;h=9e8fbfd36f8c32da11b083a527476ae2e8154606;hb=dfd413a5f54bd450850b5e84886949bcdf85b1e7;hp=dd45d104768a80ec8c722ec8169c133dc0854a70;hpb=90808c138de511a81b6b85d22a9400007d91336b;p=apitrace diff --git a/image/image_raw.cpp b/image/image_raw.cpp index dd45d10..9e8fbfd 100644 --- a/image/image_raw.cpp +++ b/image/image_raw.cpp @@ -30,18 +30,37 @@ #include #include +#include + #include "image.hpp" namespace image { + void -Image::writeRAW(std::ostream &os) const { +Image::writeRAW(std::ostream &os) const +{ + assert(channelType == TYPE_UNORM8); + const unsigned char *row; for (row = start(); row != end(); row += stride()) { - os.write((const char *)row, width*channels); + os.write((const char *)row, width*channels*bytesPerPixel); + } +} + + +bool +Image::writeRAW(const char *filename) const +{ + std::ofstream os(filename, std::ofstream::binary); + if (!os) { + return false; } + writeRAW(os); + return true; } + } /* namespace image */