MrSID Decode SDK for Raster Reference Manual  9.5.5.5244
DecodeJP2ToJPG.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 JPEG 2000 file to a
// (old-style) JPEG file, by constructing a pipeline consisting of a
// J2KImageReader which feeds into a JpegImageWriter.
#include "main.h"
#include "support.h"
#include "lt_fileSpec.h"
#include "lti_scene.h"
#include "J2KImageReader.h"
LT_USE_NAMESPACE(LizardTech);
LT_STATUS DecodeJP2ToJPG()
{
// make the image reader
const LTFileSpec fileSpec(INPUT_PATH("meg_cr20.jp2"));
TEST_BOOL(reader != nullptr);
TEST_SUCCESS(reader->initialize(fileSpec));
// make the JPG writer
TEST_SUCCESS(writer.initialize(reader));
// set up the output file
TEST_SUCCESS(writer.setOutputFileSpec(OUTPUT_PATH("meg_cr20_magP5.jpg")));
// 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.jpg"), INPUT_PATH("meg_cr20_magP5.jpg")));
Remove(OUTPUT_PATH("meg_cr20_magP5.jpg"));
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
image reader for JPEG 2000 images
LT_STATUS initialize(const LTFileSpec &fileSpec, bool isPersistent=true, float maxBpp=-1.0f, bool useWorldFile=true)
initializer
static J2KImageReader * create(void)
writes an image stage to a JPEG file
LT_STATUS initialize(LTIImageStage *imageStage, lt_int32 quality=0, lt_int32 smoothing=0)
initialize
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
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

Extensis