Пример #1
0
bool FileFormatInstance::Open( ImageDescriptionArray& images,
                               const String& filePath, const IsoString& hints )
{
   images.Clear();

   if ( (*API->FileFormat->OpenImageFileEx)( handle, filePath.c_str(), hints.c_str(), 0/*flags*/ ) == api_false )
      return false;

   for ( uint32 i = 0, n = (*API->FileFormat->GetImageCount)( handle ); i < n; ++i )
   {
      IsoString id;
      size_type len = 0;
      (*API->FileFormat->GetImageId)( handle, 0, &len, i );
      if ( len > 0 )
      {
         id.SetLength( len );
         if ( (*API->FileFormat->GetImageId)( handle, id.Begin(), &len, i ) == api_false )
            throw APIFunctionError( "GetImageId" );
         id.ResizeToNullTerminated();
      }

      api_image_info info;
      api_image_options options;
      if ( (*API->FileFormat->GetImageDescription)( handle, &info, &options, i ) == api_false )
         throw APIFunctionError( "GetImageDescription" );

      ImageDescription d;
      d.id = id;
      APIImageInfoToPCL( d.info, info );
      APIImageOptionsToPCL( d.options, options );
      images.Add( d );
   }

   return true;
}
Пример #2
0
//static
bool GradientsBase::loadFile(const String& rsFilePath_p, std::size_t index_p, imageType_t &rImage_p)
{

  // open read only
  FileFormat format( pcl::File::ExtractExtension( rsFilePath_p ), true, false );
  FileFormatInstance file(format);
  ImageDescriptionArray images;
  if ( !file.Open( images, rsFilePath_p)) //, inputHints ) )
    throw CatchedException();
  if(images.Length()<=index_p) {
    //image with this index does not exist
    return false;
  }
  TimeMessage startLoad("Loading image "+rsFilePath_p+" "+String(index_p));
  file.SelectImage(index_p);
  if (!file.ReadImage(rImage_p))
    throw CatchedException();
  return true;
}
Пример #3
0
ImageDescriptionArray JPEGInstance::Open( const String& filePath, const IsoString& /*hints*/ )
{
   Close();

   try
   {
      Exception::EnableConsoleOutput();

      reader = new JPEGReader;
      reader->Open( filePath );

      ImageDescriptionArray a;
      a.Add( ImageDescription( reader->Info(), reader->Options() ) );
      return a;
   }
   catch ( ... )
   {
      if ( reader != 0 )
         delete reader, reader = 0;
      throw;
   }
}