コード例 #1
0
// -----------------------------------------------------------------------------
// CPhSrvResourceManager::ConstructL
// 
// Symbian OS 2nd phase constructor
// -----------------------------------------------------------------------------
//
void CPhSrvResourceManager::ConstructL()
    {
    TFileName resourceFile( KPhCltServerZDrive );
    resourceFile.Append( KDC_RESOURCE_FILES_DIR );
    resourceFile.Append( KPhClientAndServerResourceFileName );
    resourceFile.Append( KPhClientAndServerResourceFileExtensionNoWild );
    resourceFile.ZeroTerminate();

    BaflUtils::NearestLanguageFile( iFsSession, resourceFile );
    iResourceFile.OpenL( iFsSession, resourceFile );
    iResourceFile.ConfirmSignatureL( KPhSrvMagicResourceFileSignature );
    }
コード例 #2
0
ファイル: ctkPluginFramework.cpp プロジェクト: lygstate/CTK
//----------------------------------------------------------------------------
QByteArray ctkPluginFramework::getResource(const QString& path) const
{
  QString resourcePath = QString(":/") + ctkPluginConstants::SYSTEM_PLUGIN_SYMBOLICNAME;
  if (path.startsWith('/'))
    resourcePath += path;
  else
    resourcePath += QString("/") + path;

  QFile resourceFile(resourcePath);
  resourceFile.open(QIODevice::ReadOnly);
  return resourceFile.readAll();
}
コード例 #3
0
ファイル: QmitkStyleManager.cpp プロジェクト: Cdebus/MITK
QIcon QmitkStyleManager::ThemeIcon(const QString &resourcePath)
{
  QFile resourceFile(resourcePath);

  if (resourceFile.open(QIODevice::ReadOnly))
  {
    auto originalSVG = resourceFile.readAll();
    return ThemeIcon(originalSVG);
  }

  MITK_WARN << "Could not read " << resourcePath.toStdString();
  return QIcon();
}
コード例 #4
0
// ---------------------------------------------------------------------------
// 
// ---------------------------------------------------------------------------
//
void CCapabilityManager::GetPhoneConfigL()
    {
    FLOG(_L("[IMAGEPRINTUI]>>> :CCapabilityManager, GetPhoneConfigL BEGIN"));
    
        
    TBuf<KResource> resourceFile(PathInfo::RomRootPath());
    TBuf<KResource> length(KPhoneCapability);    
    resourceFile.SetLength(KDriver + length.Length());
    resourceFile.Replace(KDriver, length.Length(), KPhoneCapability);
    
    RResourceFile resource;
    resource.OpenL(CCoeEnv::Static()->FsSession(),  resourceFile);
    FLOG(_L("[IMAGEPRINTUI]>>> CImagePrintUi:CCapabilityManager, Resource open"));
    
    CleanupClosePushL(resource);
    resource.ConfirmSignatureL(KPhoneCapabilityVersion);
    
    HBufC8* id = resource.AllocReadLC(PHONECAPABILITY_CONFIG);
    
    TResourceReader reader;
    reader.SetBuffer(id);   
    
    TInt qualityCount = reader.ReadUint8();
    TInt papersizeCount = reader.ReadUint8();
    TInt layoutCount  = reader.ReadUint8();
      
       
    for (TInt i = 0; i < qualityCount; i++)
    	{
    	iPhoneSuppQuality.AppendL(reader.ReadUint16());
    	}
    FLOG(_L("[IMAGEPRINTUI]>>> CImagePrintUi:CCapabilityManager, quality readed"));
    	
    for (TInt i = 0; i < papersizeCount; i++)
    	{
       	iPhoneSuppPaperSize.AppendL(reader.ReadUint16());
    	}		
    
    FLOG(_L("[IMAGEPRINTUI]>>> CImagePrintUi:CCapabilityManager, papersize readed"));
    for (TInt i = 0; i < layoutCount; i++)
    	{
    	iPhoneSuppLayout.AppendL(reader.ReadUint16());
    	}
    FLOG(_L("[IMAGEPRINTUI]>>> CImagePrintUi:CCapabilityManager, layout readed"));
    	
    CleanupStack::PopAndDestroy(id);
    CleanupStack::PopAndDestroy(&resource);
    FLOG(_L("[IMAGEPRINTUI]<<< CImagePrintUi:CCapabilityManager GetPhoneConfigL END "));
    }
コード例 #5
0
ファイル: gesturenode.cpp プロジェクト: blobfish/cadseer
osg::Geode* gsn::buildIconGeode(const char *resourceName)
{
  //alright this sucks. getting svg icons onto geode is a pain.
  //I tried something I found on the web, but looks like ass.
  //the openscenegraph svg reader only takes a filename.
  //so we will write out the resource files to the temp directory
  //so we can pass a file name to the svg reader. I don't like it either.
  QString alteredFileName(resourceName);
  alteredFileName.remove(":");
  alteredFileName.replace("/", "_");
  QDir tempDirectory = QDir::temp();
  QString resourceFileName(tempDirectory.absolutePath() + "/" + alteredFileName);
  if (!tempDirectory.exists(alteredFileName))
  {
    QFile resourceFile(resourceName);
    if (!resourceFile.open(QIODevice::ReadOnly | QIODevice::Text))
      qDebug() << "couldn't resource file";
    QByteArray buffer = resourceFile.readAll();
    resourceFile.close();
     
    QFile newFile(resourceFileName);
    if (!newFile.open(QIODevice::WriteOnly | QIODevice::Text))
      qDebug() << "couldn't open new temp file";
    qDebug() << "newfilename is: " << resourceFileName;
    newFile.write(buffer);
    newFile.close();
  }
  
  
  
  osg::ref_ptr<osg::Image> image = osgDB::readImageFile(resourceFileName.toStdString());
  assert(image.valid());
  
  osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D();
  texture->setImage(image);
  texture->setDataVariance(osg::Object::DYNAMIC);
  texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
  texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
  texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
  texture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
  
  osg::Vec2Array* textureCoordinates = new osg::Vec2Array();
  
  double radius = 32.0;
  double sides = 32.0;
  osg::Vec3d currentPoint(radius, 0.0, 0.0);
  std::vector<osg::Vec3d> points;
  points.push_back(osg::Vec3d(0.0, 0.0, 0.0));
  textureCoordinates->push_back(osg::Vec2(0.5, 0.5));
  osg::Quat rotation(2 * M_PI / sides , osg::Vec3d(0.0, 0.0, 1.0));
  for (int index = 0; index < sides; ++index)
  {
    points.push_back(currentPoint);
    osg::Vec3 tempPointVec(currentPoint);
    tempPointVec.normalize();
    osg::Vec2 tempTextVec(tempPointVec.x(), tempPointVec.y());
    textureCoordinates->push_back((tempTextVec * 0.5) + osg::Vec2(0.5, 0.5));
    currentPoint = rotation * currentPoint;
  }
  points.push_back(osg::Vec3d(radius, 0.0, 0.0));
  textureCoordinates->push_back(textureCoordinates->at(1));
  
  osg::ref_ptr<osg::BlendFunc> blendFunc = new osg::BlendFunc;
  blendFunc->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  
  osg::Geometry *geometry = new osg::Geometry();
  geometry->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture.get());
  geometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
  geometry->getOrCreateStateSet()->setAttributeAndModes(blendFunc);
  geometry->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
  
  osg::Vec3Array *vertices = new osg::Vec3Array();
  std::vector<osg::Vec3d>::const_iterator it;
  for (it = points.begin(); it != points.end(); ++it)
    vertices->push_back(*it);
  geometry->setVertexArray(vertices);
  
  geometry->setTexCoordArray(0, textureCoordinates);
  
  osg::Vec3Array *normals = new osg::Vec3Array();
  normals->push_back(osg::Vec3(0.0, 0.0, 1.0));
  geometry->setNormalArray(normals);
  geometry->setNormalBinding(osg::Geometry::BIND_OVERALL);
  
  geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLE_FAN, 0, vertices->size()));
  
  osg::Geode *geode = new osg::Geode();
  geode->addDrawable(geometry);
  return geode;
  
/* this was looking terrible
    QImage qImageBase(resourceName);
    //I am hoping that osg will free this memory.
    QImage *qImage = new QImage(QGLWidget::convertToGLFormat(qImageBase));
    unsigned char *imageData = qImage->bits();
    osg::ref_ptr<osg::Image> osgImage = new osg::Image();
    osgImage->setImage(qImage->width(), qImage->height(), 1, GL_RGBA, GL_RGBA,
                       GL_UNSIGNED_BYTE, imageData, osg::Image::USE_NEW_DELETE, 1);
    osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
    texture->setImage(osgImage.get());

    float width = static_cast<float>(qImage->width());
    float height = static_cast<float>(qImage->height());
    osg::ref_ptr<osg::Drawable> quad = osg::createTexturedQuadGeometry
            (osg::Vec3(width/-2.0, height/-2.0, 0.0), osg::Vec3(width, 0.0, 0.0f),
             osg::Vec3(0.0, height, 0.0f));
    quad->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture.get());
    quad->getOrCreateStateSet()->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
*/
}