Ejemplo n.º 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;
}
Ejemplo n.º 2
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;
   }
}