MrSID Decode SDK for Raster Reference Manual  9.5.5.5244
GeoScene.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 use geographic coordinate information
// to make decode requests. We will write the middle of the image
// out to a raw file.
#include "main.h"
#include "support.h"
#include "lt_fileSpec.h"
#include "lti_navigator.h"
LT_USE_NAMESPACE(LizardTech);
LT_STATUS GeoScene()
{
// make the image reader
const LTFileSpec fileSpec(INPUT_PATH("meg_cr20.sid"));
TEST_BOOL(reader != nullptr);
TEST_SUCCESS(reader->initialize(fileSpec));
// create a navigator; initially it is set to the whole image
LTINavigator nav(*reader);
const double pixelWidth = reader->getWidth();
const double pixelHeight = reader->getHeight();
const double halfPixelWidth = pixelWidth / 2.0;
const double halfPixelHeight = pixelHeight / 2.0;
const double quarterPixelWidth = pixelWidth / 4.0;
const double quarterPixelHeight = pixelHeight / 4.0;
// set up a scene in the middle of the image, using geo coordinates
const LTIGeoCoord& geo = reader->getGeoCoord();
double geoCenterX = geo.getX() + (geo.getXRes() * halfPixelWidth);
double geoCenterY = geo.getY() + (geo.getYRes() * halfPixelHeight);
double ulx = geoCenterX - (geo.getXRes() * quarterPixelWidth);
double uly = geoCenterY - (geo.getYRes() * quarterPixelHeight);
double lrx = geoCenterX + (geo.getXRes() * quarterPixelWidth);
double lry = geoCenterY + (geo.getYRes() * quarterPixelHeight);
TEST_SUCCESS(nav.setSceneAsGeoULLR(ulx, uly, lrx, lry, 2.0));
const LTIScene& scene = nav.getScene();
// make the raw writer
TEST_SUCCESS(writer.initialize(reader));
// set up the output file
TEST_SUCCESS(writer.setOutputFileSpec(OUTPUT_PATH("meg_geo.raw")));
// write the scene to the file
TEST_SUCCESS(writer.write(scene));
TEST_BOOL(Compare(OUTPUT_PATH("meg_geo.raw"), INPUT_PATH("meg_geo.raw")));
Remove(OUTPUT_PATH("meg_geo.raw"));
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
Represents a file or directory path.
Definition: lt_fileSpec.h:35
represents a geographic coordinate
Definition: lti_geoCoord.h:28
double getXRes() const
get the X resolution
double getY() const
get the upper-left Y position
double getX() const
get the upper-left X position
double getYRes() const
get the Y resolution
virtual LT_STATUS setOutputFileSpec(const LTFileSpec &fileSpec)
set output file name
lt_uint32 getHeight() const
get image height
lt_uint32 getWidth() const
get image width
const LTIGeoCoord & getGeoCoord() const
get the geographic coordinates of the image
virtual LT_STATUS write(const LTIScene &scene)
write (encode) a scene to the output format
provides LTIScene movement control
Definition: lti_navigator.h:26
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