コード例 #1
0
ファイル: CGViewer.cpp プロジェクト: cezarygerard/arpservice
boost::shared_ptr<SDL_Surface> CGViewer::loadImage(const std::string& filename)
{
    boost::shared_ptr<SDL_Surface> loadedImage(
            IMG_Load(filename.c_str()),
            boost::bind(&SafeFreeSurface, _1));
    if (!loadedImage.get())
        throw std::runtime_error(IMG_GetError());

	//dostosowanie grafiki do wyswietlenia z kanalem przezroczystosci
    boost::shared_ptr<SDL_Surface> optimizedImage( 
			SDL_DisplayFormatAlpha(loadedImage.get()), 
			boost::bind(&SafeFreeSurface, _1) ); 

    return optimizedImage;
}
コード例 #2
0
      Image ResourceLoader::loadImage(const std::string& imageFileName)
      {
        std::string imageFullPath = resolveImagePath(imageFileName);

        int width;
        int height;
        int channels;

        unsigned char* imageData = SOIL_load_image(imageFullPath.c_str(), &width, &height, &channels, SOIL_LOAD_AUTO);
        if (!imageData || (channels != 3) || (channels != 4))
        {
          throw ResourceLoader::ResourceInvalid(imageFullPath);
        }

        Image loadedImage(width, height, (channels == 3) ? GL_RGB : GL_RGBA, reinterpret_cast<const uint8_t*>(imageData));
        SOIL_free_image_data(imageData);

        return std::move(loadedImage);
      }
コード例 #3
0
void PicLoader::loadPicture(const QString &fileName)
{
    // запоминаем директорию и список её файлов
    setNewDir(fileName);
    m_currentFile = fileName.mid(fileName.lastIndexOf("/") + 1);

    // загружаем изображение
    QImage *image = new QImage(fileName);
    if (image->isNull())
    {
        QMessageBox::about(
            NULL,
            QString::fromUtf8("Failed loading"),
            QString::fromUtf8("Image wasn't loaded correctly.\nPlease, try again."));
        return;
    }

    emit loadedImage(image);
}
コード例 #4
0
bool FormImageProp::loadFile(const QString &fileName)
{
    QFileInfo fileInfo(fileName);
    QImage _image;

    // Targa support added
    if(fileInfo.completeSuffix().compare("tga") == 0){
        TargaImage tgaImage;
        _image = tgaImage.read(fileName);
    }else{
        QImageReader loadedImage(fileName);
        _image = loadedImage.read();
    }

    if (_image.isNull()) {
        QMessageBox::information(this, QGuiApplication::applicationDisplayName(),
                                 tr("Cannot load %1.").arg(QDir::toNativeSeparators(fileName)));
        return false;
    }
    if(bOpenNormalMapMixer){
        qDebug() << "<FormImageProp> Open normal mixer image:" << fileName;

        imageProp.glWidget_ptr->makeCurrent();
        if(glIsTexture(imageProp.normalMixerInputTexId)) imageProp.glWidget_ptr->deleteTexture(imageProp.normalMixerInputTexId);
        imageProp.normalMixerInputTexId = imageProp.glWidget_ptr->bindTexture(_image,GL_TEXTURE_2D);
        ui->labelNormalMixerInfo->setText("Current image:"+ fileInfo.baseName());
        emit imageChanged();

    }else{
        qDebug() << "<FormImageProp> Open image:" << fileName;

        imageName = fileInfo.baseName();
        (*recentDir).setPath(fileName);
        image    = _image;
        imageProp.init(image);

        //emit imageChanged();
        emit imageLoaded(image.width(),image.height());
    }
    return true;
}
コード例 #5
0
bool FormMaterialIndicesManager::loadFile(const QString &fileName)
{
    QFileInfo fileInfo(fileName);
    QImage _image;

    // Targa support added
    if(fileInfo.completeSuffix().compare("tga") == 0){
        TargaImage tgaImage;
        _image = tgaImage.read(fileName);
    }else{
        QImageReader loadedImage(fileName);
        _image = loadedImage.read();
    }

    if (_image.isNull()) {
        QMessageBox::information(this, QGuiApplication::applicationDisplayName(),
                                 tr("Cannot load material image %1.").arg(QDir::toNativeSeparators(fileName)));
        return false;
    }

    qDebug() << "<FormImageProp> Open material image:" << fileName;


    (*FormImageProp::recentDir).setPath(fileName);

    int mIndex = FBOImageProporties::currentMaterialIndeks;
    if(updateMaterials(_image)){
          image    = _image;
          imageProp.init(image);
          emit materialChanged();
          FBOImageProporties::currentMaterialIndeks = mIndex;
          emit imageLoaded(image.width(),image.height());
          // repaint all materials
          if(FBOImageProporties::currentMaterialIndeks != MATERIALS_DISABLED){
              toggleMaterials(true);
          }
    }
    return true;
}