Skip to content

Commit

Permalink
Merge pull request #105 from mdaus/byte_provider_update
Browse files Browse the repository at this point in the history
CompressedByteProvider can return a single image buffer
  • Loading branch information
asylvest authored Nov 27, 2018
2 parents 9f7dbba + ddc9872 commit e03d21f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
15 changes: 0 additions & 15 deletions modules/c++/nitf/source/ByteProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,6 @@
#include <nitf/IOStreamWriter.hpp>
#include <io/ByteStream.h>

namespace
{
void copyFromStreamAndClear(io::ByteStream& stream,
std::vector<sys::byte>& rawBytes)
{
rawBytes.resize(stream.getSize());
if (!rawBytes.empty())
{
::memcpy(&rawBytes[0], stream.get(), stream.getSize());
}

stream.clear();
}
}

namespace nitf
{
ByteProvider::ByteProvider() :
Expand Down
16 changes: 9 additions & 7 deletions modules/c++/nitf/source/CompressedByteProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,17 @@ size_t CompressedByteProvider::addImageData(
}

// Copy the image data into the buffer
size_t bytesWritten = 0;
for (size_t ii = blockRange.mStartElement;
ii < blockRange.mStartElement + blockRange.mNumElements;
++ii)
// Since we have it in contiguous memory, this can be added as one buffer
size_t numBufferBytes(0);
for (size_t ii = blockRange.mStartElement, end = blockRange.endElement();
ii < end;
++ii)
{
buffers.pushBack(imageData + bytesWritten, bytesPerBlock[ii]);
bytesWritten += bytesPerBlock[ii];
numBufferBytes += bytesPerBlock[ii];
}
return bytesWritten;
buffers.pushBack(imageData, numBufferBytes);

return numBufferBytes;
}

nitf::Off CompressedByteProvider::getNumBytes(size_t startRow, size_t numRows) const
Expand Down

0 comments on commit e03d21f

Please sign in to comment.