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; }
ImageVariant View::Image() const { image_handle hImg = (*API->View->GetViewImage)( handle ); if ( hImg != 0 ) { uint32 bitsPerSample; api_bool isFloat; if ( !(*API->SharedImage->GetImageFormat)( hImg, &bitsPerSample, &isFloat ) ) throw APIFunctionError( "GetImageFormat" ); /* * Use a private ImageVariant constructor that forces image ownership by * ImageVariant. This constructor is selected with the second dummy int * argument (set to zero below). */ if ( isFloat ) switch ( bitsPerSample ) { case 32 : return ImageVariant( new pcl::Image( hImg ), 0 ); case 64 : return ImageVariant( new pcl::DImage( hImg ), 0 ); } else switch ( bitsPerSample ) { case 8 : return ImageVariant( new pcl::UInt8Image( hImg ), 0 ); case 16 : return ImageVariant( new pcl::UInt16Image( hImg ), 0 ); case 32 : return ImageVariant( new pcl::UInt32Image( hImg ), 0 ); } } return ImageVariant(); }
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; }