コード例 #1
0
QIcon EditorDescriptor::GetImageDescriptor() const
{
    if (testImage)
    {
        testImage = false;
        if (imageDesc.isNull())
        {
            QString imageFileName(this->GetImageFilename());
            QString command(this->GetFileName());
            if (!imageFileName.isEmpty() && configurationElement)
            {
                imageDesc = AbstractUICTKPlugin::ImageDescriptorFromPlugin(
                                configurationElement->GetContributor()->GetName(), imageFileName);
            }
            else if (!command.isEmpty())
            {
                //imageDesc = WorkbenchImages.getImageDescriptorFromProgram(
                //    command, 0);
            }
        }
        this->VerifyImage();
    }

    return imageDesc;
}
コード例 #2
0
	//------------------------------
	BitmapTex* MaterialCreator::createTexture( const COLLADAFW::EffectCommon& effectCommon, const COLLADAFW::Texture& texture )
	{
		BitmapTex* bitmapTexture = NewDefaultBitmapTex();
		COLLADAFW::SamplerID samplerId = texture.getSamplerId();
		const COLLADAFW::Sampler* sampler = effectCommon.getSamplerPointerArray()[ samplerId ];

		const COLLADAFW::UniqueId& imageUniqueId = sampler->getSourceImage();
		const COLLADAFW::Image* image = getFWImageByUniqueId( imageUniqueId );

		if ( !image )
			return 0;

		COLLADABU::URI imageUri( getFileInfo().absoluteFileUri, image->getImageURI().getURIString() );
		COLLADABU::NativeString imageFileName( imageUri.toNativePath().c_str(), COLLADABU::NativeString::ENCODING_UTF8 );
		bitmapTexture->SetMapName(const_cast<char*>(imageFileName.c_str()));
		bitmapTexture->LoadMapFiles(0);

		UVGen* uvGen = bitmapTexture->GetTheUVGen();
		StdUVGen* stdUVGen = (StdUVGen*)uvGen;

		// reset all flags
		//stdUVGen->SetFlag(U_WRAP|V_WRAP, 1);
		//stdUVGen->SetFlag(U_MIRROR|V_MIRROR, 0);
		int tiling = 0;
		
		if ( sampler->getWrapS() == COLLADAFW::Sampler::WRAP_MODE_WRAP )
		{
			tiling += 1<<0;
		}
		else if ( sampler->getWrapS() == COLLADAFW::Sampler::WRAP_MODE_MIRROR )
		{
			tiling += 1<<2;
		}

		if ( sampler->getWrapT() == COLLADAFW::Sampler::WRAP_MODE_WRAP )
		{
			tiling += 1<<1;
		}
		else if ( sampler->getWrapT() == COLLADAFW::Sampler::WRAP_MODE_MIRROR )
		{
			tiling += 1<<3;
		}

		stdUVGen->SetTextureTiling(tiling);


		return bitmapTexture;
	}
コード例 #3
0
ファイル: httpserver.cpp プロジェクト: foucar/CASS
void req_histogram2DPage::createResponseBuffer()
{
  _responseBuffer = "";
  _responseBuffer += "<html><head> <meta http-equiv=\"refresh\" content=\"1\"></head><body>\n";
  //_responseBuffer += "<html><head><title>2D Histogram</title></head><body>\n";

  std::string imageFileName( ADDR_HIST2DImage );
  int dotpos = _address.find_last_of(".");
  imageFileName += _address.substr( 0, dotpos );
  imageFileName += ".jpg";
  _responseBuffer += "<html><body>\n";
  _responseBuffer += "<img src=\"";
  _responseBuffer += imageFileName;
  _responseBuffer += "\" alt=\"";
  _responseBuffer += imageFileName;
  _responseBuffer += "\"></p>";
  _responseBuffer += imageFileName;
  _responseBuffer += "\n";
  _responseBuffer += "</body></html>\n";
}
コード例 #4
0
ファイル: TileMapImporter.cpp プロジェクト: RandomShaper/GD
bool TileMapImporter::ImportTileMap(TileSet &tileSet, TileMap &tileMap,
                                    bool importTileMap, bool importTileSetConf, bool importTileSetImage,
                                    bool importHitboxes, gd::Project &project)
{
    //Checks the map type
    if(m_map->GetOrientation() != Tmx::TMX_MO_ORTHOGONAL)
    {
        gd::LogError(_("Only orthogonal maps are supported !"));
        return false;
    }

    //Get the tileset list
    if(m_map->GetNumTilesets() < 1)
    {
        gd::LogError(_("There are no tilesets in this file !"));
        return false;
    }
    else if(m_map->GetNumTilesets() > 1)
    {
        gd::LogWarning(_("Only the first tileset will be taken into account. Tiles from supplementary tilesets may be lost."));
    }

    //Import the tileset image if needed
    if(importTileSetImage)
    {
        const Tmx::Image *importedImage = m_map->GetTileset(0)->GetImage();
        wxFileName imageFileName(importedImage->GetSource());
        imageFileName.MakeAbsolute(wxFileName(m_filePath).GetPath());

        if(!imageFileName.FileExists())
        {
            gd::LogError(_("The image can't be found !"));
            return false;
        }

        gd::String newResourceName = gd::NewNameGenerator::Generate(
                                         u8"imported_" + imageFileName.GetFullName(),
                                         [&project](const gd::String &name) -> bool { return project.GetResourcesManager().HasResource(name); }
                                     );

        gd::LogMessage(_("The image is imported as ") + "\"" + newResourceName + "\".");

        imageFileName.MakeRelativeTo(wxFileName(project.GetProjectFile()).GetPath());
        project.GetResourcesManager().AddResource(newResourceName, imageFileName.GetFullPath(), "image");

        tileSet.textureName = newResourceName;

        //Reload the texture
        tileSet.LoadResources(project);

        gd::LogStatus(_("Tileset image importation completed."));
    }

    //Import the tileset configuration if wanted
    if(importTileSetConf)
    {
        const Tmx::Tileset *importedTileset = m_map->GetTileset(0);

        if(importedTileset->GetImage()->GetWidth() != tileSet.GetWxBitmap().GetWidth() ||
                importedTileset->GetImage()->GetHeight() != tileSet.GetWxBitmap().GetHeight())
        {
            gd::LogWarning(_("Tileset image size is not the same. Some tiles may not be rendered correctly."));
        }

        tileSet.tileSize.x = importedTileset->GetTileWidth();
        tileSet.tileSize.y = importedTileset->GetTileHeight();
        tileSet.tileSpacing.x = tileSet.tileSpacing.y = importedTileset->GetSpacing();

        if(importedTileset->GetMargin() > 0)
        {
            gd::LogWarning(_("Tilemap objects don't handle tilesets with margins around the images. Consider cutting the picture."));
        }

        gd::LogStatus(_("Tileset configuration importation completed."));
    }

    //Import the tilemap tiles if wanted
    if(importTileMap)
    {
        //Tilemap size
        if(tileMap.GetColumnsCount() != m_map->GetWidth() || tileMap.GetRowsCount() != m_map->GetHeight())
            gd::LogMessage(_("Tilemap size is different."));
        tileMap.SetSize(0, 0);
        tileMap.SetSize(m_map->GetWidth(), m_map->GetHeight());

        if(!importTileSetConf && !importTileSetImage)
            CheckTilesCount(tileSet);

        //Import layers and tiles
        if(m_map->GetNumTileLayers() > 3)
        {
            gd::LogWarning(_("There are more than 3 tiles layers. Only the 3 firsts will be imported."));
        }
        else if(m_map->GetNumTileLayers() < 3)
        {
            gd::LogMessage(_("There are less than 3 tiles layers. Upper layer(s) will be empty."));
        }

        for(std::size_t i = 0; i < std::min(3, m_map->GetNumTileLayers()); i++)
        {
            const Tmx::TileLayer *layer = m_map->GetTileLayer(i);

            for(std::size_t x = 0; x < tileMap.GetColumnsCount(); x++)
            {
                for(std::size_t y = 0; y < tileMap.GetRowsCount(); y++)
                {
                    //Only tiles provided by the first tileset are imported (and also tests for empty tiles)
                    if(m_map->FindTilesetIndex(layer->GetTileGid(x, y)) == 0)
                    {
                        tileMap.SetTile(i, x, y, layer->GetTileId(x, y));
                    }
                }
            }
        }

        gd::LogStatus(_("Tilemap content importation completed."));
    }

    //Import the hitboxes
    if(importHitboxes)
    {
        const Tmx::Tileset *importedTileset = m_map->GetTileset(0);

        //Set all tiles not collidable in the tileset
        tileSet.ResetHitboxes();
        for(std::size_t i = 0; i < tileSet.GetTilesCount(); i++)
            tileSet.SetTileCollidable(i, false);

        if(!importTileSetConf && !importTileSetImage)
            CheckTilesCount(tileSet);

        bool hasMoreThanOneObjectPerTile = false;
        bool hasNotPolygoneObject = false;
        bool hasNotConvexPolygon = false;
        for(auto it = importedTileset->GetTiles().cbegin();
                it != importedTileset->GetTiles().cend();
                ++it)
        {
            const Tmx::Tile *importedTile = *it;

            if(importedTile->GetId() < tileSet.GetTilesCount()) //Check if the tileset has enough tiles to receive the imported hitboxes
            {
                if(importedTile->HasObjects())
                {
                    //Set the tile collidable and gets its hitbox
                    tileSet.SetTileCollidable(importedTile->GetId(), true);
                    TileHitbox &tileHitbox = tileSet.GetTileHitboxRef(importedTile->GetId());

                    //Warn the user if more than one hitbox per tile is found
                    if(importedTile->GetNumObjects() > 1)
                        hasMoreThanOneObjectPerTile = true;

                    const Tmx::Object *importedObj = importedTile->GetObject(0);
                    if(!importedObj->GetPolyline() && !importedObj->GetEllipse())
                    {
                        Polygon2d polygonHitbox;

                        if(!importedObj->GetPolygon())
                        {
                            //This is a rectangle
                            polygonHitbox = Polygon2d::CreateRectangle(importedObj->GetWidth(), importedObj->GetHeight());
                            polygonHitbox.Move(
                                importedObj->GetWidth() / 2.f,
                                importedObj->GetHeight() / 2.f
                            );
                        }
                        else
                        {
                            //This is a polygon
                            const Tmx::Polygon *importedPolygon = importedObj->GetPolygon();

                            for(int i = 0; i < importedPolygon->GetNumPoints(); i++)
                            {
                                polygonHitbox.vertices.emplace_back(
                                    importedPolygon->GetPoint(i).x,
                                    importedPolygon->GetPoint(i).y
                                );
                            }
                        }

                        polygonHitbox.Move(importedObj->GetX(), importedObj->GetY());
                        polygonHitbox.Rotate(importedObj->GetRot());

                        if(polygonHitbox.IsConvex())
                            tileHitbox.hitbox = polygonHitbox;
                        else
                            hasNotConvexPolygon = true;
                    }
                    else
                    {
                        //This is not a supported shape
                        hasNotPolygoneObject = true;
                    }
                }
            }
        }

        if(hasMoreThanOneObjectPerTile)
            gd::LogWarning(_("Some tiles have more than 1 hitbox. Only the first one is imported."));
        if(hasNotPolygoneObject)
            gd::LogWarning(_("Some tiles have a polyline or a ellipsis hitbox. Only rectangle and polygon hitboxes are supported."));
        if(hasNotConvexPolygon)
            gd::LogWarning(_("Some tiles have a concave polygon. It has been ignored and set to a rectangular hitbox as this object only supports convex hitboxes for tiles."));

        gd::LogStatus(_("Tiles hitboxes importation completed."));
    }

    return true;
}
コード例 #5
0
void QmitkToFRecorderWidget::OnStartRecorder()
{
  m_Controls->m_StartRecordingButton->setChecked(true);
  m_Controls->m_RecorderGroupBox->setEnabled(false);
  this->repaint();

  int numOfFrames = m_Controls->m_NumOfFramesSpinBox->value();
  try
  {
    bool fileOK = true;
    bool distanceImageSelected = true;
    bool amplitudeImageSelected = false;
    bool intensityImageSelected = false;
    bool rgbImageSelected = false;
    bool rawDataSelected = false;

    //Set check boxes in dialog according to device properties
    m_ToFImageGrabber->GetCameraDevice()->GetBoolProperty("HasAmplitudeImage",amplitudeImageSelected);
    m_ToFImageGrabber->GetCameraDevice()->GetBoolProperty("HasIntensityImage",intensityImageSelected);
    m_ToFImageGrabber->GetCameraDevice()->GetBoolProperty("HasRGBImage",rgbImageSelected);

    QString tmpFileName("");
    QString selectedFilter("");
    QString imageFileName("");
    mitk::ToFImageWriter::ToFImageType tofImageType;
    tmpFileName = QmitkToFRecorderWidget::getSaveFileName(tofImageType,
      distanceImageSelected, amplitudeImageSelected, intensityImageSelected, rgbImageSelected, rawDataSelected,
      NULL, "Save Image To...", imageFileName, "NRRD Images (*.nrrd);;PIC Images - deprecated (*.pic);;Text (*.csv)", &selectedFilter);

    if (tmpFileName.isEmpty())
    {
      fileOK = false;
    }
    else
    {
      imageFileName = tmpFileName;
    }

    if (fileOK)
    {
      std::string dir = itksys::SystemTools::GetFilenamePath( imageFileName.toStdString() );
      std::string baseFilename = itksys::SystemTools::GetFilenameWithoutLastExtension( imageFileName.toStdString() );
      std::string extension = itksys::SystemTools::GetFilenameLastExtension( imageFileName.toStdString() );

      int integrationTime = this->m_ToFImageGrabber->GetIntegrationTime();
      int modulationFreq = this->m_ToFImageGrabber->GetModulationFrequency();

      QString integrationTimeStr;
      integrationTimeStr.setNum(integrationTime);
      QString modulationFreqStr;
      modulationFreqStr.setNum(modulationFreq);
      QString numOfFramesStr("");
      if (this->m_RecordMode == mitk::ToFImageRecorder::PerFrames)
      {
        numOfFramesStr.setNum(numOfFrames);
      }

      std::string distImageFileName = prepareFilename(dir, baseFilename, modulationFreqStr.toStdString(),
        integrationTimeStr.toStdString(), numOfFramesStr.toStdString(), extension, "_DistanceImage");
      MITK_INFO << "Save distance data to: " << distImageFileName;

      std::string amplImageFileName = prepareFilename(dir, baseFilename, modulationFreqStr.toStdString(),
        integrationTimeStr.toStdString(), numOfFramesStr.toStdString(), extension, "_AmplitudeImage");
      MITK_INFO << "Save amplitude data to: " << amplImageFileName;

      std::string intenImageFileName = prepareFilename(dir, baseFilename, modulationFreqStr.toStdString(),
        integrationTimeStr.toStdString(), numOfFramesStr.toStdString(), extension, "_IntensityImage");
      MITK_INFO << "Save intensity data to: " << intenImageFileName;

      std::string rgbImageFileName = prepareFilename(dir, baseFilename, modulationFreqStr.toStdString(),
        integrationTimeStr.toStdString(), numOfFramesStr.toStdString(), extension, "_RGBImage");
      MITK_INFO << "Save intensity data to: " << rgbImageFileName;

      if (selectedFilter.compare("Text (*.csv)") == 0)
      {
        this->m_ToFImageRecorder->SetFileFormat(".csv");
      }
      else if (selectedFilter.compare("PIC Images - deprecated (*.pic)") == 0)
      {
        //default
        this->m_ToFImageRecorder->SetFileFormat(".pic");

        QMessageBox::warning(NULL, "Deprecated File Format!",
          "Please note that *.pic file format is deprecated and not longer supported! The suggested file format for images is *.nrrd!");
      }
      else if (selectedFilter.compare("NRRD Images (*.nrrd)") == 0)
      {
        this->m_ToFImageRecorder->SetFileFormat(".nrrd");
      }
      else
      {
        QMessageBox::warning(NULL, "Unsupported file format!", "Please specify one of the supported file formats *.nrrd, *.csv!");
        return;
      }

      numOfFrames = m_Controls->m_NumOfFramesSpinBox->value();
      this->m_ToFImageRecorder->SetDistanceImageFileName(distImageFileName);
      this->m_ToFImageRecorder->SetAmplitudeImageFileName(amplImageFileName);
      this->m_ToFImageRecorder->SetIntensityImageFileName(intenImageFileName);
      this->m_ToFImageRecorder->SetRGBImageFileName(rgbImageFileName);
      this->m_ToFImageRecorder->SetToFImageType(tofImageType);
      this->m_ToFImageRecorder->SetDistanceImageSelected(distanceImageSelected);
      this->m_ToFImageRecorder->SetAmplitudeImageSelected(amplitudeImageSelected);
      this->m_ToFImageRecorder->SetIntensityImageSelected(intensityImageSelected);
      this->m_ToFImageRecorder->SetRGBImageSelected(rgbImageSelected);
      this->m_ToFImageRecorder->SetRecordMode(this->m_RecordMode);
      this->m_ToFImageRecorder->SetNumOfFrames(numOfFrames);

      emit RecordingStarted();
      this->m_ToFImageRecorder->StartRecording();
    }
    else
    {
      this->OnRecordingStopped();
    }
  }
  catch(std::exception& e)
  {
    QMessageBox::critical(NULL, "Error", QString(e.what()));
    this->OnRecordingStopped();
  }
}