Example #1
0
   static api_bool api_func ValidateProcessImageExecution( const_image_handle hImage, const_process_handle hp, char16_type* whyNot, uint32 maxLen )
   {
      try
      {
         uint32 bitsPerSample;
         api_bool isFloat;
         if ( !(*API->SharedImage->GetImageFormat)( hImage, &bitsPerSample, &isFloat ) )
            throw 0;

         ImageVariant image;
         void* h = const_cast<image_handle>( hImage );
         if ( isFloat )
            switch ( bitsPerSample )
            {
            case 32 :
               image = ImageVariant( new pcl::Image( h ) );
               break;
            case 64 :
               image = ImageVariant( new pcl::DImage( h ) );
               break;
            default :
               return api_false; // ?!
            }
         else
            switch ( bitsPerSample )
            {
            case  8 :
               image = ImageVariant( new UInt8Image( h ) );
               break;
            case 16 :
               image = ImageVariant( new UInt16Image( h ) );
               break;
            case 32 :
               image = ImageVariant( new UInt32Image( h ) );
               break;
            default :
               return api_false; // ?!
            }

         image.SetOwnership( true );

         String whyNotStr;
         bool ok = constInstance->CanExecuteOn( image, whyNotStr );

         if ( !ok && !whyNotStr.IsEmpty() && whyNot != 0 && maxLen > 0 )
               whyNotStr.c_copy( whyNot, maxLen );

         return api_bool( ok );
      }
      ERROR_HANDLER
      return api_false;
   }
Example #2
0
   static api_bool api_func ExecuteProcessImage( image_handle hImage, process_handle hp, const char* hints, uint32/*flags*/ )
   {
      try
      {
         uint32 bitsPerSample;
         api_bool isFloat;
         if ( !(*API->SharedImage->GetImageFormat)( hImage, &bitsPerSample, &isFloat ) )
            throw 0;

         ImageVariant image;
         if ( isFloat )
            switch ( bitsPerSample )
            {
            case 32 :
               image = ImageVariant( new pcl::Image( hImage ) );
               break;
            case 64 :
               image = ImageVariant( new pcl::DImage( hImage ) );
               break;
            default :
               return api_false; // ?!
            }
         else
            switch ( bitsPerSample )
            {
            case  8 :
               image = ImageVariant( new UInt8Image( hImage ) );
               break;
            case 16 :
               image = ImageVariant( new UInt16Image( hImage ) );
               break;
            case 32 :
               image = ImageVariant( new UInt32Image( hImage ) );
               break;
            default :
               return api_false; // ?!
            }

         image.SetOwnership( true );

         bool wasConsoleOutput = Exception::IsConsoleOutputEnabled();
         bool wasGUIOutput = Exception::IsGUIOutputEnabled();

         try
         {
            Exception::EnableConsoleOutput();
            Exception::EnableGUIOutput();

            api_bool retVal = (api_bool)instance->ExecuteOn( image, hints );

            Exception::EnableConsoleOutput( wasConsoleOutput );
            Exception::EnableGUIOutput( wasGUIOutput );

            return retVal;
         }
         catch ( ... )
         {
            Exception::EnableConsoleOutput( wasConsoleOutput );
            Exception::EnableGUIOutput( wasGUIOutput );
            throw;
         }
      }
      ERROR_HANDLER
      return api_false;
   }