MrSID Decode SDK for Raster Reference Manual  9.5.5.5244
Pipeline.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 example shows the use of a complex image pipeline: we will take an
// RGB image, convert it to greyscale, crop it, and write it out to disk.
// The input and output formats are both raw.
#include "main.h"
#include "support.h"
#include "lti_pixel.h"
#include "lti_scene.h"
#include "lti_cropFilter.h"
LT_USE_NAMESPACE(LizardTech);
LT_STATUS Pipeline()
{
// make the raw image reader
TEST_BOOL(reader != nullptr);
TEST_SUCCESS(reader->initialize(INPUT_PATH("meg.bip"), inputProps, 640, 480));
// make the RGB -> greyscale filter
TEST_BOOL(colorFilter != nullptr);
const LTIPixel grayPixel(LTI_COLORSPACE_GRAYSCALE, 1, reader->getDataType());
TEST_SUCCESS(colorFilter->initialize(reader, grayPixel));
// prove the color transform worked
TEST_BOOL(colorFilter->getColorSpace() == LTI_COLORSPACE_GRAYSCALE);
// crop it to remove the outer 20 pixels on each edge
TEST_BOOL(cropFilter != nullptr);
TEST_SUCCESS(cropFilter->initialize(colorFilter, 20, 20, 600, 440));
// prove the crop worked
TEST_BOOL(cropFilter->getWidth() == 600);
TEST_BOOL(cropFilter->getHeight() == 440);
// make the raw writer
TEST_SUCCESS(writer.initialize(cropFilter));
// set up the output file
TEST_SUCCESS(writer.setOutputFileSpec(OUTPUT_PATH("meg_filter.raw")));
// we will use the whole (cropped) image
const LTIScene scene(0, 0, 600, 440, 1.0);
// write the scene to the file
TEST_SUCCESS(writer.write(scene));
// verify we got the right output
TEST_BOOL(Compare(OUTPUT_PATH("meg_filter.raw"), INPUT_PATH("meg_filter.raw")));
Remove(OUTPUT_PATH("meg_filter.raw"));
cropFilter->release();
cropFilter = nullptr;
colorFilter->release();
colorFilter = nullptr;
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
@ LTI_DATATYPE_UINT8
Definition: lti_types.h:103
@ LTI_COLORSPACE_GRAYSCALE
Definition: lti_types.h:40
@ LTI_COLORSPACE_RGB
Definition: lti_types.h:46
change the colorspace of the image
LT_STATUS initialize(LTIImageStage *srcImage, const LTIPixel &dstPixel)
initializer
static LTIColorTransformer * create(void)
crops the image stage to a smaller width and height
LT_STATUS initialize(LTIImageStage *srcImage, lt_int32 xOffset, lt_int32 yOffset, lt_int32 newWidth, lt_int32 newHeight)
initializer
static LTICropFilter * create(void)
virtual LT_STATUS setOutputFileSpec(const LTFileSpec &fileSpec)
set output file name
LTIColorSpace getColorSpace() const
get colorspace
virtual LT_STATUS write(const LTIScene &scene)
write (encode) a scene to the output format
basic properties of a pixel
Definition: lti_pixel.h:32
class for reading RAW files
static LTIRawImageReader * create(void)
LT_STATUS initialize(LTIOStreamInf *stream, const LTIPixel &pixelProps, lt_uint32 width, lt_uint32 height, bool useWorldFile=true)
initialize (stream)
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

Extensis