#include "main.h"
#include "support.h"
LT_USE_NAMESPACE(LizardTech);
#ifdef WIN32_DLL_WORKAROUND
template <class T>
class LTIDLLFileStream : public T
{
public:
LTIDLLFileStream() {}
virtual ~LTIDLLFileStream() {}
};
#endif
{
public:
{
return sts;
#ifdef WIN32_DLL_WORKAROUND
m_stream = new LTIDLLFileStream<LTIOFileStream>;
#else
#endif
if (!m_stream)
sts = m_stream->open();
return sts;
return sts;
return sts;
return sts;
}
lt_int64 getPhysicalFileSize(
void)
const
{
return siz;
}
protected:
{
const lt_uint32 sceneRowBytes = numCols * bytesPerPixel;
m_rowBuffer =
new lt_uint8[sceneRowBytes];
}
{
const lt_uint32 sceneRowBytes = numCols * bytesPerPixel;
for (
lt_uint32 row = 0; row < numRows; row++)
{
return sts;
if (m_stream->read(m_rowBuffer, sceneRowBytes) != sceneRowBytes)
return m_stream->getLastError();
for(
lt_uint16 band = 0; band < numBands; band++)
{
const lt_uint8 *src = m_rowBuffer + band * bytesPerSample;
dst += row * totalNumCols * bytesPerSample;
for(
lt_uint32 col = 0; col < numCols; col++, src += bytesPerPixel, dst += bytesPerSample)
memcpy(dst, src, bytesPerSample);
}
curPos += m_rowBytes;
}
}
{
delete [] m_rowBuffer;
m_rowBuffer = nullptr;
}
{
return m_stream != nullptr ? m_stream->getID() : nullptr;
}
private:
#ifdef WIN32_DLL_WORKAROUND
LTIDLLFileStream<LTIOFileStream> *m_stream;
#else
#endif
};
MyReader::MyReader() :
m_stream(nullptr),
m_rowBuffer(nullptr),
m_rowBytes(0)
{
}
MyReader::~MyReader()
{
m_stream->close();
delete m_stream;
delete[] m_rowBuffer;
}
MyReader*
MyReader::create()
{
return new MyReader;
}
{
MyReader *reader = MyReader::create();
TEST_BOOL(reader != nullptr);
TEST_SUCCESS(reader->initialize(fileSpec, pixel, 640, 480));
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"));
Remove(OUTPUT_PATH("meg.hdr"));
reader->release();
reader = nullptr;
}
#define LTI_REFERENCE_COUNTED_BOILERPLATE(classname)
@ LTIO_SEEK_DIR_BEG
Offset from the beginning of the file.
@ LTIO_SEEK_DIR_END
Offset from the end of the file (offsets need to be negative to be valid)
lt_uint32 LT_STATUS
An integral status code.
#define LT_STS_Uninit
status code indicating unintialized variable
#define LT_SUCCESS(err)
checks return value for success status
#define LT_STS_Failure
status code indicating failure
#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
long long int lt_int64
signed 64-bit integer
Represents a file or directory path.
virtual LT_STATUS initialize(const LTFileSpec &fs, const char *mode)
Initializes the stream from a file spec.
writes an image stage to a BBB file
virtual LT_STATUS setOutputFileSpec(const LTFileSpec &fileSpec)
set output file name
LTIDataType getDataType() const
get data type
abstract class for implementing an image reader
virtual const char * getSourceName(void) const =0
LT_STATUS init(const LTIImage *image=nullptr)
virtual LT_STATUS decodeBegin(const LTIPixel &pixelProps, const LTIScene &fullScene)=0
start strip-based read
virtual LT_STATUS decodeStrip(LTISceneBuffer &stripBuffer, const LTIScene &stripScene)=0
read a strip from the image
virtual LT_STATUS decodeEnd(void)=0
finish strip-based read
LT_STATUS setDimensions(lt_uint32 width, lt_uint32 height)
set width and height of the image
lt_uint32 getWidth() const
get image width
LT_STATUS setPixelProps(const LTIPixel &pixelProps)
set pixel properties of the image
const LTIPixel & getPixelProps() const
get the pixel properties of the image
LT_STATUS setDefaultGeoCoord(const LTIImage &image)
set the geographic coordinates of the image
virtual LT_STATUS write(const LTIScene &scene)
write (encode) a scene to the output format
basic properties of a pixel
LTIDataType getDataType() const
get the sample datatype
LTISample & getSample(lt_uint16) const
lt_uint32 getNumBytes() const
get the size of a pixel
LT_STATUS initialize(LTIImageStage *imageStage)
initialization function
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
lt_int32 getUpperLeftRow() const
returns the y-position of the upper-left point
lt_int32 getUpperLeftCol() const
returns the x-position of the upper-left point
class to hold data passed between image stages
lt_int32 getTotalNumCols() const
get width of (entire) buffer
void * getBandData(lt_uint16 band) const
get pointer to data (for 1 band)
lt_uint16 getNumBands() const
get number of bands
const LTIPixel & getPixelProps() const
get pixel type of buffer
void byteSwap()
export to memory (BSQ)
static bool needsSwapping(LTIDataType datatype, LTIEndian byteOrder)