MrSID Decode SDK for Raster Reference Manual  9.5.5.5244
DecodeMrSIDToRaw.cpp
//
// This code is property of Celartem, Inc dba Extensis.
// Copyright (c) 1995-2023. All rights reserved.
// Use permitted only under license from Extensis.
//
/* PUBLIC */
// This demonstrates how to decode a scene from a MrSID file to a
// raw file, by constructing a pipeline consisting of a MrSIDImageReader
// which feeds into an LTIRawImageWriter.
#include "main.h"
#include "support.h"
#include "lt_fileSpec.h"
#include "lti_scene.h"
LT_USE_NAMESPACE(LizardTech);
LT_STATUS DecodeMrSIDToRaw()
{
// make the image reader
const LTFileSpec fileSpec(INPUT_PATH("meg_cr20.sid"));
TEST_BOOL(reader != nullptr);
TEST_SUCCESS(reader->initialize(fileSpec));
// make the raw writer
TEST_SUCCESS(writer.initialize(reader));
// set up the output file
TEST_SUCCESS(writer.setOutputFileSpec(OUTPUT_PATH("meg_cr20_magP5_sid.bip")));
// we will decode the whole image at half resolution
lt_uint32 w = 0, h = 0;
TEST_SUCCESS(reader->getDimsAtMag(0.5, w, h));
const LTIScene scene(0, 0, w, h, 0.5);
// write the scene to the file
TEST_SUCCESS(writer.write(scene));
// verify we got the right output
TEST_BOOL(Compare(OUTPUT_PATH("meg_cr20_magP5_sid.bip"), INPUT_PATH("meg_cr20_magP5_sid.bip")));
Remove(OUTPUT_PATH("meg_cr20_magP5_sid.bip"));
reader->release();
reader = nullptr;
}
lt_uint32 LT_STATUS
An integral status code.
Definition: lt_status.h:30
#define LT_STS_Uninit
status code indicating unintialized variable
Definition: lt_status.h:60
#define LT_STS_Success
status code indicating success
Definition: lt_status.h:43
unsigned int lt_uint32
unsigned 32-bit integer
Definition: lt_types.h:44
Represents a file or directory path.
Definition: lt_fileSpec.h:35
virtual LT_STATUS setOutputFileSpec(const LTFileSpec &fileSpec)
set output file name
LT_STATUS getDimsAtMag(double mag, lt_uint32 &width, lt_uint32 &height) const
get image width and height at given magnification
virtual LT_STATUS write(const LTIScene &scene)
write (encode) a scene to the output format
class for writing RAW files
LT_STATUS initialize(LTIImageStage *imageStage)
initialization function
virtual void release(void) const
decrement the reference counter and delete the object when the counter is zero
representation of a scene
Definition: lti_scene.h:60
reader for MrSID images (MG2, MG3 and MG4)
LT_STATUS initialize(const LTFileSpec &fileSpec, bool useWorldFile=false, MrSIDMemoryUsage memoryUsage=MRSID_MEMORY_USAGE_DEFAULT, MrSIDStreamUsage streamUsage=MRSID_STREAM_USAGE_DEFAULT)
initializer
static MrSIDImageReader * create(void)

Extensis