我是WinRT C++的新手。我試圖從C#傳遞一個StorageFile圖像並打開該文件並將其設置爲WinRT中BitmapImage中的源以提取圖像的高度和寬度。我正在使用下面的代碼。WinRT中的BitmapImage SetSourceAsync C++
auto openOperation = StorageImageFile->OpenAsync(FileAccessMode::Read); // from http://msdn.microsoft.com/en-us/library/windows/desktop/hh780393%28v=vs.85%29.aspx
openOperation->Completed = ref new
AsyncOperationCompletedHandler<IRandomAccessStream^>(
[=](IAsyncOperation<IRandomAccessStream^> ^operation, AsyncStatus status)
{
auto Imagestream = operation->GetResults();
BitmapImage^ bmp = ref new BitmapImage();
auto bmpOp = bmp->SetSourceAsync(Imagestream);
bmpOp->Completed = ref new
AsyncActionCompletedHandler (
[=](IAsyncAction^ action, AsyncStatus status)
{
action->GetResults();
UINT32 imageWidth = (UINT32)bmp->PixelWidth;
UINT32 imageHeight = (UINT32)bmp->PixelHeight;
});
});
此代碼似乎不起作用。在BitmapImage之後^ bmp = ref new BitmapImage();調試器停止說沒有找到源代碼。 你能幫我寫出正確的代碼嗎?
我想你的意思是寫'openOperation-> Completed' **'+ =''**參考新...'和'bmpOp- >已完成'**'+ ='**'ref new ...' – 2014-09-19 15:28:11