2022-11-23 15:41:33 +00:00
|
|
|
#include "ImageBitStream.h"
|
|
|
|
|
|
|
|
ImageBitStream::ImageBitStream(Image<unsigned char>* image)
|
|
|
|
: BitStream(),
|
|
|
|
mImage(image)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ImageBitStream::isFinished() const
|
|
|
|
{
|
2022-11-24 16:15:41 +00:00
|
|
|
return mByteOffset == mImage->getDataRef().size();
|
2022-11-23 15:41:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<unsigned char> ImageBitStream::peekNextNBytes(unsigned n) const
|
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
std::optional<unsigned char> ImageBitStream::readNextByte()
|
|
|
|
{
|
2022-11-24 16:15:41 +00:00
|
|
|
mByteOffset++;
|
|
|
|
|
|
|
|
if (isFinished() )
|
|
|
|
{
|
|
|
|
return std::nullopt;
|
|
|
|
}
|
|
|
|
const auto val = mImage->getDataRef()[mByteOffset];
|
|
|
|
return val;
|
2022-11-23 15:41:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ImageBitStream::writeByte(unsigned char data)
|
|
|
|
{
|
2022-11-25 09:43:14 +00:00
|
|
|
mByteOffset++;
|
2022-11-23 15:41:33 +00:00
|
|
|
|
2022-11-25 09:43:14 +00:00
|
|
|
if (isFinished() )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mImage->setDataItem(mByteOffset, data);
|
2022-11-23 15:41:33 +00:00
|
|
|
}
|
|
|
|
|