Added ImageOptions for use with the GDAL plugin
This commit is contained in:
114
include/osgDB/ImageOptions
Normal file
114
include/osgDB/ImageOptions
Normal file
@@ -0,0 +1,114 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OSGDB_IMAGEOPTIONS
|
||||
#define OSGDB_IMAGEOPTIONS 1
|
||||
|
||||
#include <osgDB/ReaderWriter>
|
||||
|
||||
namespace osgDB {
|
||||
|
||||
class OSGDB_EXPORT ImageOptions : public osgDB::ReaderWriter::Options
|
||||
{
|
||||
public:
|
||||
|
||||
ImageOptions();
|
||||
|
||||
ImageOptions(const std::string& str);
|
||||
|
||||
/** RatioWindow stores the window (as ratios of 0.0 to 1.0) from the overall imagery from which to extract the osg::Image*/
|
||||
struct RatioWindow
|
||||
{
|
||||
RatioWindow():
|
||||
windowX(0.0),
|
||||
windowY(0.0),
|
||||
windowWidth(1.0),
|
||||
windowHeight(1.0) {}
|
||||
|
||||
void set(double x, double y, double w, double h)
|
||||
{
|
||||
windowX = x;
|
||||
windowY = y;
|
||||
windowWidth = w;
|
||||
windowHeight = h;
|
||||
}
|
||||
|
||||
double windowX;
|
||||
double windowY;
|
||||
double windowWidth;
|
||||
double windowHeight;
|
||||
};
|
||||
|
||||
/** PixelWindow stores the window (in exact pixels) from the overall imagery from which to extract the osg::Image*/
|
||||
struct PixelWindow
|
||||
{
|
||||
PixelWindow():
|
||||
windowX(0),
|
||||
windowY(0),
|
||||
windowWidth(0),
|
||||
windowHeight(0) {}
|
||||
|
||||
void set(unsigned int x, unsigned int y, unsigned int w, unsigned int h)
|
||||
{
|
||||
windowX = x;
|
||||
windowY = y;
|
||||
windowWidth = w;
|
||||
windowHeight = h;
|
||||
}
|
||||
|
||||
unsigned int windowX;
|
||||
unsigned int windowY;
|
||||
unsigned int windowWidth;
|
||||
unsigned int windowHeight;
|
||||
};
|
||||
|
||||
enum ImageWindowMode
|
||||
{
|
||||
ALL_IMAGE,
|
||||
RATIO_WINDOW,
|
||||
PIXEL_WINDOW
|
||||
};
|
||||
|
||||
enum ImageSamplingMode
|
||||
{
|
||||
NEAREST,
|
||||
LINEAR,
|
||||
CUBIC
|
||||
};
|
||||
|
||||
// source
|
||||
ImageSamplingMode _sourceImageSamplingMode;
|
||||
ImageWindowMode _sourceImageWindowMode;
|
||||
RatioWindow _sourceRatioWindow;
|
||||
PixelWindow _sourcePixelWindow;
|
||||
|
||||
|
||||
|
||||
// destination
|
||||
osg::ref_ptr<osg::Image> _destinationImage;
|
||||
|
||||
ImageWindowMode _destinationImageWindowMode;
|
||||
RatioWindow _destinationRatioWindow;
|
||||
PixelWindow _destinationPixelWindow;
|
||||
|
||||
GLenum _destinationDataType;
|
||||
GLenum _destinationPixelFormat;
|
||||
|
||||
void init();
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // OSGDB_IMAGEOPTIONS
|
||||
25
src/osgDB/ImageOptions.cpp
Normal file
25
src/osgDB/ImageOptions.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <osgDB/ImageOptions>
|
||||
|
||||
|
||||
using namespace osgDB;
|
||||
|
||||
|
||||
ImageOptions::ImageOptions()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
ImageOptions::ImageOptions(const std::string& str)
|
||||
{
|
||||
init();
|
||||
_str = str;
|
||||
}
|
||||
|
||||
|
||||
void ImageOptions::init()
|
||||
{
|
||||
_sourceImageSamplingMode = NEAREST;
|
||||
_sourceImageWindowMode = ALL_IMAGE;
|
||||
|
||||
_destinationImageWindowMode = ALL_IMAGE;
|
||||
}
|
||||
Reference in New Issue
Block a user