locked
Why is BitmapDecoder's CreateAsync unhappy with BitmapDecoder::JpegDecoderId ?

    Question

  • void metro::ImagePage::ShrinkImage_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
    {
    	using namespace Windows::Storage;
    	using namespace Windows::Storage::Pickers;
    	using namespace Windows::Storage::Streams;
    	using namespace Windows::UI::Xaml::Media::Imaging;
    	using namespace concurrency;
    	using namespace Windows::Graphics::Imaging;
    
    	auto picker= ref new FileOpenPicker();
    	picker->ViewMode = PickerViewMode::Thumbnail;
    	picker->SuggestedStartLocation = PickerLocationId::Desktop;
       	picker->FileTypeFilter->Append(".jpg");	// Required 
    	picker->FileTypeFilter->Append(".jpeg");
    	picker->FileTypeFilter->Append(".png");
    
    	task< StorageFile^ > getFileTask ( picker->PickSingleFileAsync() ); 
    
    	getFileTask.then( [] ( StorageFile^ jpgFile ) 
    	{
    		task< IRandomAccessStream^ > getStreamTask ( jpgFile->OpenAsync(FileAccessMode::Read) ); 
    
    		getStreamTask.then( [ ]( IRandomAccessStream^ jpgStream ) 
    		{
    			auto size= jpgStream->Size;
    
    			// This works, 
    			// task< BitmapDecoder^ > getDecoderTask ( BitmapDecoder::CreateAsync( jpgStream ) );								
    
    			// but adding a specific Platform::Guid crashes with
    			// Unhandled exception at 0x5E028AE3 (msvcr110d.dll) in metro.exe: An invalid parameter was passed to a function that considers invalid parameters fatal.
    			task< BitmapDecoder^ > getDecoderTask ( BitmapDecoder::CreateAsync( BitmapDecoder::JpegDecoderId, jpgStream ) );
    		});
    
    	});
    
    }
    
    
    The one parameter BitmapDecoder::CreateAsync works, but the two parameter BitmapDecoder::CreateAsync fails with an "

    An invalid parameter" and gives this call stack:

    > msvcr110d.dll!_invoke_watson(const wchar_t * pszExpression, const wchar_t * pszFunction, const wchar_t * pszFile, unsigned int nLine, unsigned int pReserved) Line 131 C++
      vccorlib110d.dll!__abi_FailFast() Line 18 C++
      metro.exe!?__abi_Windows_Foundation_?$AsyncOperationCompletedHandler@P$AAVBitmapDecoder@Imaging@Graphics@Windows@@___abi_IDelegate____abi_Invoke@?Q__abi_IDelegate@?$AsyncOperationCompletedHandler@P$AAVBitmapDecoder@Imaging@Graphics@Windows@@@Foundation@Windows@@234@U$AAGJP$AAU?$IAsyncOperation@P$AAVBitmapDecoder@Imaging@Graphics@Windows@@@34@W4AsyncStatus@34@@Z(Windows::Foundation::IAsyncOperation<Windows::Graphics::Imaging::BitmapDecoder ^> ^ __param0, Windows::Foundation::AsyncStatus __param1) C++

    I am assuming that the problem rests in the BitmapDecoder::JpegDecoderId.

    I have seen similar C# code:

         BitmapDecoder decoder = await BitmapDecoder.CreateAsync(BitmapDecoder.JpegDecoderId, jpgstream);
            

    Does this make sense to anyone?  


    Monday, August 27, 2012 12:48 PM

Answers

All replies