#include "main.h"
#include "support.h"
LT_USE_NAMESPACE(LizardTech);
{
public:
MyWriter(void) :
m_rowBytes(0),
m_rowBuffer(nullptr)
{
}
~MyWriter()
{
}
{
}
{
const lt_uint32 bytesPerPixel = m_image->getPixelProps().getNumBytes();
m_rowBytes = numCols * bytesPerPixel;
}
{
for (
lt_uint32 row = 0; row < numRows; row++)
{
for(
lt_uint16 band = 0; band < numBands; band++)
{
lt_uint8 *dst = m_rowBuffer + band * bytesPerSample;
src += row * totalNumCols * bytesPerSample;
for(
lt_uint32 col = 0; col < numCols; col++, src += bytesPerSample, dst += bytesPerPixel)
memcpy(dst, src, bytesPerSample);
}
if(stream.
write(m_rowBuffer, m_rowBytes) != m_rowBytes)
}
}
{
delete [] m_rowBuffer;
m_rowBuffer = nullptr;
}
private:
};
{
TEST_BOOL(reader != nullptr);
MyWriter writer;
TEST_SUCCESS(writer.initialize(reader));
TEST_SUCCESS(writer.setOutputFileSpec(OUTPUT_PATH("meg.bip")));
const LTIScene scene(0, 0, 640, 480, 1.0);
TEST_SUCCESS(writer.write(scene));
TEST_BOOL(Compare(OUTPUT_PATH("meg.bip"), INPUT_PATH("meg.bip")));
Remove(OUTPUT_PATH("meg.bip"));
reader->release();
reader = nullptr;
}
lt_uint32 LT_STATUS
An integral status code.
#define LT_STS_Uninit
status code indicating unintialized variable
#define LT_STS_Success
status code indicating success
unsigned short lt_uint16
unsigned 16-bit integer
unsigned char lt_uint8
unsigned 8-bit integer
unsigned int lt_uint32
unsigned 32-bit integer
Represents a file or directory path.
Abstract definition of a stream.
virtual LT_STATUS getLastError() const =0
Get status code of last error event.
virtual lt_uint32 write(const lt_uint8 *pSrc, lt_uint32 numBytes)=0
Store the specified number of bytes in the data source.
read an image from a BBB file
LT_STATUS initialize(const LTFileSpec &fileSpec, bool useWorldFile=true)
intializer
static LTIBBBImageReader * create(void)
class for writing geographic images to files or streams
virtual LT_STATUS writeBegin(const LTIScene &scene)
begin an encode (write) operation
virtual LT_STATUS writeStrip(LTISceneBuffer &stripBuffer, const LTIScene &stripScene)=0
encode one strip of the scene
virtual LT_STATUS writeEnd(void)
complete an encode (write) operation
LTIOStreamInf * getStream() const
get underlying stream
abstract class for decoding from an image
LT_STATUS init(LTIImageStage *imageStage)
initialization function
basic properties of a pixel
LTIDataType getDataType() const
get the sample datatype
lt_uint32 getNumBytes() const
get the size of a pixel
LTISample & getSample(lt_uint16) const
lt_uint32 getNumBytes() const
get the size of a sample
representation of a scene
lt_int32 getNumRows() const
returns the height of the scene
lt_int32 getNumCols() const
returns the width of the scene
class to hold data passed between image stages
const LTIPixel & getPixelProps() const
get pixel type of buffer
lt_int32 getTotalNumCols() const
get width of (entire) buffer
lt_uint16 getNumBands() const
get number of bands
void byteSwap()
export to memory (BSQ)
void * getBandData(lt_uint16 band) const
get pointer to data (for 1 band)
static bool needsSwapping(LTIDataType datatype, LTIEndian byteOrder)