stuff-from-scratch/src/image/ImageBitStream.cpp
2022-11-28 10:16:04 +00:00

42 lines
747 B
C++

#include "ImageBitStream.h"
ImageBitStream::ImageBitStream(Image<unsigned char>* image)
: BitStream(),
mImage(image)
{
}
bool ImageBitStream::isFinished() const
{
return mByteOffset == mImage->getDataRef().size();
}
std::vector<unsigned char> ImageBitStream::peekNextNBytes(unsigned n) const
{
return {};
}
std::optional<unsigned char> ImageBitStream::readNextByte()
{
mByteOffset++;
if (isFinished() )
{
return std::nullopt;
}
const auto val = mImage->getDataRef()[mByteOffset];
return val;
}
void ImageBitStream::writeByte(unsigned char data, bool checkOverflow )
{
mByteOffset++;
if (isFinished() )
{
return;
}
mImage->setDataItem(mByteOffset, data);
}