本文整理汇总了C++中ogre::Image::load方法的典型用法代码示例。如果您正苦于以下问题:C++ Image::load方法的具体用法?C++ Image::load怎么用?C++ Image::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Image
的用法示例。
在下文中一共展示了Image::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadResource
void gkTextureLoader::loadResource(Ogre::Resource* resource)
{
Ogre::Texture* texture = static_cast<Ogre::Texture*>(resource);
if (!m_stream)
{
gkPrintf("Warning: Skipping image %s no packed file information is present!", texture->getName().c_str());
return;
}
Ogre::DataStreamPtr stream(OGRE_NEW Ogre::MemoryDataStream(m_stream->ptr(), m_stream->size()));
Ogre::Image ima;
ima.load(stream);
texture->setUsage(Ogre::TU_DEFAULT);
texture->setTextureType(Ogre::TEX_TYPE_2D);
texture->setNumMipmaps(gkEngine::getSingleton().getUserDefs().defaultMipMap);
texture->setWidth(ima.getWidth());
texture->setHeight(ima.getHeight());
texture->setDepth(ima.getDepth());
texture->setFormat(ima.getFormat());
Ogre::ConstImagePtrList ptrs;
ptrs.push_back(&ima);
texture->_loadImages(ptrs);
}
示例2: initBlendMaps
void SnowTerrain::initBlendMaps(Terrain* terrain)
{
TextureLayerFileList blendImages = mSnowConfig->terrainSettings.textureBlendFileList;
// load those blendmaps into the layers
for(int j = 0;j < terrain->getLayerCount();j++)
{
// skip first layer
if(j==0)
continue;
// no blend map for this layer
if(blendImages.size() >= j && blendImages[j].length() == 0)
continue;
Ogre::TerrainLayerBlendMap *blendmap = terrain->getLayerBlendMap(j);
Ogre::Image img;
img.load(blendImages[j],"General");
int blendmapsize = terrain->getLayerBlendMapSize();
if(img.getWidth() != blendmapsize)
img.resize(blendmapsize, blendmapsize);
float *ptr = blendmap->getBlendPointer();
Ogre::uint8 *data = static_cast<Ogre::uint8*>(img.getPixelBox().data);
for(int bp = 0;bp < blendmapsize * blendmapsize;bp++)
ptr[bp] = static_cast<float>(data[bp]) / 255.0f;
blendmap->dirty();
blendmap->update();
}
}
示例3: downloadPicture
void TileDownloader::downloadPicture(unsigned int index)
{
const PictureInfo& info = mPictures[index];
//Downloading all tiles in parallel
{
boost::threadpool::pool tp(info.tiles.size());
for (unsigned int i=0; i<info.tiles.size(); ++i)
tp.schedule(boost::bind(&TileDownloader::downloadPictureTile, this, index, i));
}
//compose all tiles on the canvas
unsigned int width = info.width;
unsigned int height = info.height;
Ogre::Canvas::Context* ctx = new Ogre::Canvas::Context(width, height, false);
for (unsigned int i=0; i<info.tiles.size(); ++i)
{
const TileInfo& tileInfo = info.tiles[i];
Ogre::Image img;
std::stringstream filename;
filename << tileInfo.j << "_" << tileInfo.i << ".jpg";
img.load(filename.str(), Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
float x = (tileInfo.i == 0) ? 0 : 509.0f + (tileInfo.i-1)*510.0f;
float y = (tileInfo.j == 0) ? 0 : 509.0f + (tileInfo.j-1)*510.0f;
ctx->drawImage(img, x, y);
}
//save canvas to jpeg
ctx->saveToFile(info.filePath);
delete ctx;
}
示例4:
Ogre::Image *
MaterialPreviewDialog::getPreviewImage( const Ogre::String &textureName )
{
PreviewImageMap::iterator it = mPreviewImageMap.find(textureName);
if ( it == mPreviewImageMap.end() )
{
Ogre::Image *image = new Ogre::Image;
image->load(textureName,"General");
assert (image);
std::pair< PreviewImageMap::iterator, bool > inserted =
mPreviewImageMap.insert(PreviewImageMap::value_type(textureName,image));
assert (inserted.second);
return image;
}
else
{
assert (it->second);
return it->second;
}
}
示例5: load
//----------------------------------------------------------------------------//
Texture* OgreImageCodec::load(const RawDataContainer& data, Texture* result)
{
using namespace Ogre;
// wrap the buffer of the RawDataContainer with an Ogre::MemoryDataStream.
DataStreamPtr stream(
new MemoryDataStream(
const_cast<void*>(static_cast<const void*>(data.getDataPtr())),
data.getSize(), false));
// load the image
Ogre::Image image;
image.load(stream);
// discover the pixel format and number of pixel components
Texture::PixelFormat format;
int components;
switch (image.getFormat())
{
case PF_R8G8B8:
format = Texture::PF_RGB;
components = 3;
break;
case PF_A8R8G8B8:
format = Texture::PF_RGBA;
components = 4;
break;
default:
throw FileIOException("OgreImageCodec::load: File data was of an "
"unsupported format.");
break;
}
// do the old switcharoo on R and B...
// (we could 'fix' this in the CEGUI::OgreTexture, but that would break all
// the other ImageCodecs when used with the Ogre renderer, hence we don't)
uchar* dat = image.getData();
for (uint j = 0; j < image.getHeight(); ++j)
{
for (uint i = 0; i < image.getWidth(); ++i)
{
uchar tmp = dat[i * components + 0];
dat[i * components + 0] = dat[i * components + 2];
dat[i * components + 2] = tmp;
}
dat += image.getRowSpan();
}
// load the resulting image into the texture
result->loadFromMemory(image.getData(),
Size(image.getWidth(),
image.getHeight()),
format);
return result;
}
示例6: getTerrainImage
/// FIXME
void getTerrainImage(bool flipX, bool flipY, Ogre::Image& img)
{
img.load("height_map.png", Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
if (flipX)
img.flipAroundY();
if (flipY)
img.flipAroundX();
}
示例7: GetTerrainImage
void TerrainManager::GetTerrainImage(bool flipX, bool flipY, Ogre::Image& img)
{
img.load(mHeightMapFileName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
if (flipX)
img.flipAroundY();
if (flipY)
img.flipAroundX();
}
示例8: GetDefaultTexture
void LodTextureManager::GetDefaultTexture(Ogre::Resource* res)
{
// Create the texture
Texture* texture = static_cast<Texture*>(res);
Ogre::Image img;
img.load("pending.png",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
texture->loadImage(img);
}
示例9: fromOgreImageName
//----------------------------------------------------------------------------------------
QImage ImageConverter::fromOgreImageName(const Ogre::String& name, const Ogre::String& resourceGroup)
{
mResourceGroup = resourceGroup;
Ogre::Image img;
img.load(name, mResourceGroup);
return fromOgreImage(img);
}
示例10: getTerrainImage
void getTerrainImage(bool flipX, bool flipY, Ogre::Image& img)
{
img.load("terrain1.bmp", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
if (flipX)
img.flipAroundY();
if (flipY)
img.flipAroundX();
}
示例11: ReadLodTextureMap
void FvFTDTerrainPageSerializerImpl::ReadLodTextureMap(Ogre::DataStreamPtr &spStream,
FvTerrainPage *pkDest)
{
Ogre::Image kImage;
kImage.load(spStream,"dds");
pkDest->m_spLodMap = Ogre::TextureManager::getSingleton().loadImage(pkDest->m_kLodName,
FvTerrainPage::TERRAIN_INERNAL_RESOURCE_GROUP, kImage);
}
示例12: getTerrainImage
void OgreWidget::getTerrainImage(bool flipX, bool flipY, Ogre::Image& img)
{
img.load("terrain.png", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
qDebug() << "OgreWidget::getTerrainImage(): loaded terrain heightmap, width is" << img.getWidth();
if(flipX)
img.flipAroundY();
if(flipY)
img.flipAroundX();
}
示例13: createTerrain
void AppDemarrage::createTerrain()
{
// options globales
mTerrainOptions = OGRE_NEW Ogre::TerrainGlobalOptions();
mTerrainOptions->setMaxPixelError(8);
mTerrainOptions->setLightMapDirection(mLight->getDerivedDirection());
mTerrainOptions->setCompositeMapDistance(3000);
mTerrainOptions->setCompositeMapAmbient(mSceneMgr->getAmbientLight());
mTerrainOptions->setCompositeMapDiffuse(mLight->getDiffuseColour());
mTerrain = OGRE_NEW Ogre::Terrain(mSceneMgr);
Ogre::Image img;
img.load("terrain.png", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
// informations géométriques
Ogre::Terrain::ImportData imp;
imp.inputImage = &img;
imp.terrainSize = img.getWidth();
imp.worldSize = 8000;
imp.inputScale = 600;
imp.minBatchSize = 33;
imp.maxBatchSize = 65;
// textures
imp.layerList.resize(3);
imp.layerList[0].worldSize = 100;
imp.layerList[0].textureNames.push_back("grass_green-01_diffusespecular.dds");
imp.layerList[0].textureNames.push_back("grass_green-01_normalheight.dds");
imp.layerList[1].worldSize = 30;
imp.layerList[1].textureNames.push_back("growth_weirdfungus-03_diffusespecular.dds");
imp.layerList[1].textureNames.push_back("growth_weirdfungus-03_normalheight.dds");
imp.layerList[2].worldSize = 200;
imp.layerList[2].textureNames.push_back("dirt_grayrocky_diffusespecular.dds");
imp.layerList[2].textureNames.push_back("dirt_grayrocky_normalheight.dds");
mTerrain->prepare(imp);
mTerrain->load();
// plaquage de texture
Ogre::TerrainLayerBlendMap* blendMap1 = mTerrain->getLayerBlendMap(1);
float* pBlend1 = blendMap1->getBlendPointer();
for (Ogre::uint16 y = 0; y < mTerrain->getLayerBlendMapSize(); ++y)
{
for (Ogre::uint16 x = 0; x < mTerrain->getLayerBlendMapSize(); ++x)
{
*pBlend1++ = 150;
}
}
blendMap1->dirty();
blendMap1->update();
mTerrain->freeTemporaryResources();
}
示例14: loadTerrain
void TerrainLoader::loadTerrain(std::string filename) {
Ogre::Image img;
img.load(filename, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
terrainGroup->defineTerrain(0, 0, &img);
terrainGroup->loadAllTerrains(true);
Ogre::TerrainGroup::TerrainIterator ti = terrainGroup->getTerrainIterator();
while(ti.hasMoreElements()) {
Ogre::Terrain* t = ti.getNext()->instance;
initBlendMaps(t);
}
terrainGroup->freeTemporaryResources();
}
示例15: _setSkinType
void MouseCursor::_setSkinType(const Ogre::String type)
{
if(mSkinType == type)
return;
mSkinType = type;
Ogre::Image i;
i.load(mSkinTypeManager->getSkinType("MouseCursor",mSkinType)->getSkinElement(TEXTURE)->getTextureName(),Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
// update cursor size to match texture used
setSize(i.getWidth(),i.getHeight());
}