本文整理汇总了C++中URI::getImage方法的典型用法代码示例。如果您正苦于以下问题:C++ URI::getImage方法的具体用法?C++ URI::getImage怎么用?C++ URI::getImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URI
的用法示例。
在下文中一共展示了URI::getImage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
bool
ResourceCache::getOrCreateLineTexture(const URI& uri, osg::ref_ptr<osg::Texture>& output, const osgDB::Options* readOptions)
{
Threading::ScopedMutexLock lock(_texMutex);
TextureCache::Record rec;
if (_texCache.get(uri.full(), rec) && rec.value().valid())
{
output = rec.value().get();
}
else
{
osg::ref_ptr<osg::Image> image = uri.getImage(readOptions);
if (image.valid())
{
osg::Texture2D* tex = new osg::Texture2D(image);
tex->setWrap( osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE );
tex->setWrap( osg::Texture::WRAP_T, osg::Texture::REPEAT );
tex->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR );
tex->setFilter( osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
tex->setMaxAnisotropy( 4.0f );
tex->setResizeNonPowerOfTwoHint( false );
output = tex;
_texCache.insert(uri.full(), output.get());
}
}
return output.valid();
}
示例2: in
bool
LandCoverBiome::configure(const ConfigOptions& conf, const osgDB::Options* dbo)
{
LandCoverBiomeOptions in( conf );
if ( in.biomeClasses().isSet() )
setClasses( in.biomeClasses().get() );
for(SymbolVector::const_iterator i = in.symbols().begin(); i != in.symbols().end(); ++i)
{
const BillboardSymbol* bs = dynamic_cast<BillboardSymbol*>( i->get() );
if ( bs )
{
URI imageURI = bs->url()->evalURI();
osg::Image* image = const_cast<osg::Image*>( bs->getImage() );
if ( !image )
{
image = imageURI.getImage(dbo);
}
if ( image )
{
getBillboards().push_back( LandCoverBillboard(image, bs->width().get(), bs->height().get()) );
}
else
{
OE_WARN << LC << "Failed to load billboard image from \"" << imageURI.full() << "\"\n";
}
}
else
{
OE_WARN << LC << "Unrecognized symbol in land cover biome\n";
}
}
if ( getBillboards().size() == 0 )
{
OE_WARN << LC << "A biome failed to install any billboards.\n";
return false;
}
return true;
}
示例3: gen
void
PlaceNode::init(const osgDB::Options* dbOptions)
{
_geode = new osg::Geode();
osg::Drawable* text = 0L;
// If there's no explicit text, look to the text symbol for content.
if ( _text.empty() && _style.has<TextSymbol>() )
_text = _style.get<TextSymbol>()->content()->eval();
osg::ref_ptr<const InstanceSymbol> instance = _style.get<InstanceSymbol>();
// backwards compability, support for deprecated MarkerSymbol
if ( !instance.valid() && _style.has<MarkerSymbol>() )
instance = _style.get<MarkerSymbol>()->convertToInstanceSymbol();
const IconSymbol* icon = instance->asIcon();
if ( !_image.valid() )
{
URI imageURI;
if ( icon )
{
if ( icon->url().isSet() )
{
imageURI = URI( icon->url()->eval(), icon->url()->uriContext() );
}
}
if ( !imageURI.empty() )
{
_image = imageURI.getImage( dbOptions );
}
}
// found an image; now format it:
if ( _image.get() )
{
// this offset anchors the image at the bottom
osg::Vec2s offset;
if ( !icon || !icon->alignment().isSet() )
{
// default to bottom center
offset.set(0.0, (_image->t() / 2.0));
}
else
{ // default to bottom center
switch (icon->alignment().value())
{
case IconSymbol::ALIGN_LEFT_TOP:
offset.set((_image->s() / 2.0), -(_image->t() / 2.0));
break;
case IconSymbol::ALIGN_LEFT_CENTER:
offset.set((_image->s() / 2.0), 0.0);
break;
case IconSymbol::ALIGN_LEFT_BOTTOM:
offset.set((_image->s() / 2.0), (_image->t() / 2.0));
break;
case IconSymbol::ALIGN_CENTER_TOP:
offset.set(0.0, -(_image->t() / 2.0));
break;
case IconSymbol::ALIGN_CENTER_CENTER:
offset.set(0.0, 0.0);
break;
case IconSymbol::ALIGN_CENTER_BOTTOM:
default:
offset.set(0.0, (_image->t() / 2.0));
break;
case IconSymbol::ALIGN_RIGHT_TOP:
offset.set(-(_image->s() / 2.0), -(_image->t() / 2.0));
break;
case IconSymbol::ALIGN_RIGHT_CENTER:
offset.set(-(_image->s() / 2.0), 0.0);
break;
case IconSymbol::ALIGN_RIGHT_BOTTOM:
offset.set(-(_image->s() / 2.0), (_image->t() / 2.0));
break;
}
}
// Apply a rotation to the marker if requested:
double heading = 0.0;
if ( icon && icon->heading().isSet() )
{
heading = osg::DegreesToRadians( icon->heading()->eval() );
}
//We must actually rotate the geometry itself and not use a MatrixTransform b/c the
//decluttering doesn't respect Transforms above the drawable.
osg::Geometry* imageGeom = AnnotationUtils::createImageGeometry( _image.get(), offset, 0, heading );
if ( imageGeom )
_geode->addDrawable( imageGeom );
text = AnnotationUtils::createTextDrawable(
_text,
_style.get<TextSymbol>(),
osg::Vec3( (offset.x() + (_image->s() / 2.0) + 2), offset.y(), 0 ) );
}
else
//.........这里部分代码省略.........
示例4: getAttachPoint
void
PlaceNode::init()
{
//reset.
this->clearDecoration();
getAttachPoint()->removeChildren(0, getAttachPoint()->getNumChildren());
_geode = new osg::Geode();
osg::Drawable* text = 0L;
// If there's no explicit text, look to the text symbol for content.
if ( _text.empty() && _style.has<TextSymbol>() )
{
_text = _style.get<TextSymbol>()->content()->eval();
}
osg::ref_ptr<const InstanceSymbol> instance = _style.get<InstanceSymbol>();
// backwards compability, support for deprecated MarkerSymbol
if ( !instance.valid() && _style.has<MarkerSymbol>() )
{
instance = _style.get<MarkerSymbol>()->convertToInstanceSymbol();
}
const IconSymbol* icon = instance->asIcon();
if ( !_image.valid() )
{
URI imageURI;
if ( icon )
{
if ( icon->url().isSet() )
{
imageURI = URI( icon->url()->eval(), icon->url()->uriContext() );
}
}
if ( !imageURI.empty() )
{
_image = imageURI.getImage( _dbOptions.get() );
}
}
// found an image; now format it:
if ( _image.get() )
{
// Scale the icon if necessary
double scale = 1.0;
if ( icon && icon->scale().isSet() )
{
scale = icon->scale()->eval();
}
double s = scale * _image->s();
double t = scale * _image->t();
// this offset anchors the image at the bottom
osg::Vec2s offset;
if ( !icon || !icon->alignment().isSet() )
{
// default to bottom center
offset.set(0.0, t / 2.0);
}
else
{ // default to bottom center
switch (icon->alignment().value())
{
case IconSymbol::ALIGN_LEFT_TOP:
offset.set((s / 2.0), -(t / 2.0));
break;
case IconSymbol::ALIGN_LEFT_CENTER:
offset.set((s / 2.0), 0.0);
break;
case IconSymbol::ALIGN_LEFT_BOTTOM:
offset.set((s / 2.0), (t / 2.0));
break;
case IconSymbol::ALIGN_CENTER_TOP:
offset.set(0.0, -(t / 2.0));
break;
case IconSymbol::ALIGN_CENTER_CENTER:
offset.set(0.0, 0.0);
break;
case IconSymbol::ALIGN_CENTER_BOTTOM:
default:
offset.set(0.0, (t / 2.0));
break;
case IconSymbol::ALIGN_RIGHT_TOP:
offset.set(-(s / 2.0), -(t / 2.0));
break;
case IconSymbol::ALIGN_RIGHT_CENTER:
offset.set(-(s / 2.0), 0.0);
break;
case IconSymbol::ALIGN_RIGHT_BOTTOM:
offset.set(-(s / 2.0), (t / 2.0));
break;
}
}
// Apply a rotation to the marker if requested:
//.........这里部分代码省略.........
示例5: if
void
PlaceNode::init()
{
Decluttering::setEnabled( this->getOrCreateStateSet(), true );
osgEarth::clearChildren( getPositionAttitudeTransform() );
_geode = new osg::Geode();
// ensure that (0,0,0) is the bounding sphere control/center point.
// useful for things like horizon culling.
_geode->setComputeBoundingSphereCallback(new ControlPointCallback());
osg::Drawable* text = 0L;
// If there's no explicit text, look to the text symbol for content.
if ( _text.empty() && _style.has<TextSymbol>() )
{
_text = _style.get<TextSymbol>()->content()->eval();
}
osg::ref_ptr<const InstanceSymbol> instance = _style.get<InstanceSymbol>();
// backwards compability, support for deprecated MarkerSymbol
if ( !instance.valid() && _style.has<MarkerSymbol>() )
{
instance = _style.get<MarkerSymbol>()->convertToInstanceSymbol();
}
const IconSymbol* icon = instance->asIcon();
if ( !_image.valid() )
{
URI imageURI;
if ( icon )
{
if ( icon->url().isSet() )
{
imageURI = icon->url()->evalURI();
}
else if (icon->getImage())
{
_image = icon->getImage();
}
}
if ( !imageURI.empty() )
{
_image = imageURI.getImage( _dbOptions.get() );
}
}
osg::BoundingBox imageBox(0,0,0,0,0,0);
// found an image; now format it:
if ( _image.get() )
{
// Scale the icon if necessary
double scale = 1.0;
if ( icon && icon->scale().isSet() )
{
scale = icon->scale()->eval();
}
double s = scale * _image->s();
double t = scale * _image->t();
// this offset anchors the image at the bottom
osg::Vec2s offset;
if ( !icon || !icon->alignment().isSet() )
{
// default to bottom center
offset.set(0.0, t / 2.0);
}
else
{ // default to bottom center
switch (icon->alignment().value())
{
case IconSymbol::ALIGN_LEFT_TOP:
offset.set((s / 2.0), -(t / 2.0));
break;
case IconSymbol::ALIGN_LEFT_CENTER:
offset.set((s / 2.0), 0.0);
break;
case IconSymbol::ALIGN_LEFT_BOTTOM:
offset.set((s / 2.0), (t / 2.0));
break;
case IconSymbol::ALIGN_CENTER_TOP:
offset.set(0.0, -(t / 2.0));
break;
case IconSymbol::ALIGN_CENTER_CENTER:
offset.set(0.0, 0.0);
break;
case IconSymbol::ALIGN_CENTER_BOTTOM:
default:
offset.set(0.0, (t / 2.0));
break;
case IconSymbol::ALIGN_RIGHT_TOP:
offset.set(-(s / 2.0), -(t / 2.0));
//.........这里部分代码省略.........