MrSID Decode SDK for Raster Reference Manual 9.5.5.5244
ImageInfo.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 basic image information available from an LTIImageStage.
#include "main.h"
#include "support.h"
#include "lt_fileSpec.h"
#include "lti_geoCoord.h"
#include "lti_utils.h"
#include "lti_pixel.h"
#include "lti_sample.h"
LT_USE_NAMESPACE(LizardTech);
LT_STATUS ImageInfo()
{
// make the image reader
const LTFileSpec fileSpec(INPUT_PATH("meg_cr20.sid"));
TEST_BOOL(reader != nullptr);
TEST_SUCCESS(reader->initialize(fileSpec));
// get some information about the image
TEST_BOOL(reader->getWidth() == 640);
TEST_BOOL(reader->getHeight() == 480);
TEST_BOOL(reader->getColorSpace() == LTI_COLORSPACE_RGB);
TEST_BOOL(reader->getNumBands() == 3);
TEST_BOOL(reader->getDataType() == LTI_DATATYPE_UINT8);
TEST_BOOL(reader->getNominalImageSizeWithAlpha() == 640 * 480 * 3 * 1);
TEST_BOOL(reader->getMinMagnification() == 0.0625);
TEST_BOOL(LTIUtils::magToLevel(0.0625) == 4);
TEST_BOOL(reader->getMaxMagnification() == 1048576);
TEST_BOOL(LTIUtils::magToLevel(1048576) == -20); // (an arbitrarily large value)
const LTIGeoCoord& geo = reader->getGeoCoord();
TEST_BOOL(geo.getX() == 0.0);
TEST_BOOL(geo.getY() == 479.0);
TEST_BOOL(geo.getXRes() == 1.0);
TEST_BOOL(geo.getYRes() == -1.0);
const LTIPixel *nd = reader->getNoDataPixel();
if (nd != nullptr)
{
for (lt_uint16 b = 0; b < nd->getNumBands(); b++)
TEST_BOOL(nd->getSample(b).getValueAsDouble() == 0); // black
}
reader->release();
reader = nullptr;
}
@ LTI_DATATYPE_UINT8
Definition: lti_types.h:103
@ LTI_COLORSPACE_RGB
Definition: lti_types.h:46
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 short lt_uint16
unsigned 16-bit integer
Definition: lt_types.h:40
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
LTIDataType getDataType() const
get data type
lt_uint16 getNumBands() const
get number of bands
lt_int64 getNominalImageSizeWithAlpha() const
get the nominal size of the image, including the alpha band
LTIColorSpace getColorSpace() const
get colorspace
lt_uint32 getHeight() const
get image height
double getMaxMagnification() const
get the maximum magnification
lt_uint32 getWidth() const
get image width
double getMinMagnification() const
get the minimum magnification
const LTIPixel * getNoDataPixel() const
get the values of the "no data" (transparency) pixel
const LTIGeoCoord & getGeoCoord() const
get the geographic coordinates of the image
basic properties of a pixel
Definition: lti_pixel.h:32
LTISample & getSample(lt_uint16) const
lt_uint16 getNumBands() const
get the number of bands
virtual void release(void) const
decrement the reference counter and delete the object when the counter is zero
double getValueAsDouble() const
static lt_int32 magToLevel(double mag)
convert mag to level
reader for MrSID images (MG2, MG3 and MG4)
static MrSIDImageReader * create(void)
LT_STATUS initialize(const LTFileSpec &fileSpec, bool useWorldFile=false, MrSIDMemoryUsage memoryUsage=MRSID_MEMORY_USAGE_DEFAULT, MrSIDStreamUsage streamUsage=MRSID_STREAM_USAGE_DEFAULT)
initializer

Extensis