You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the CreateFromBytes static method in the below function seems to be impossible to build as it asks for array_view when passing IBuffer and then asking for array_view when passing IBuffer.
1>C:\Users\user\Win2DIssue\Example\MainWindow.xaml.h(46,60): error C2665: 'winrt::Microsoft::Graphics::Canvas::CanvasBitmap::CreateFromBytes': no overloaded function could convert all the argument types (compiling source file MainWindow.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\Generated Files\winrt\Microsoft.Graphics.Canvas.h(4284,31): message : could be 'winrt::Microsoft::Graphics::Canvas::CanvasBitmap winrt::Microsoft::Graphics::Canvas::CanvasBitmap::CreateFromBytes(const winrt::Microsoft::Graphics::Canvas::ICanvasResourceCreator &,const winrt::Windows::Storage::Streams::IBuffer &,int32_t,int32_t,const winrt::Windows::Graphics::DirectX::DirectXPixelFormat &)' (compiling source file MainWindow.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\MainWindow.xaml.h(46,60): message : 'winrt::Microsoft::Graphics::Canvas::CanvasBitmap winrt::Microsoft::Graphics::Canvas::CanvasBitmap::CreateFromBytes(const winrt::Microsoft::Graphics::Canvas::ICanvasResourceCreator &,const winrt::Windows::Storage::Streams::IBuffer &,int32_t,int32_t,const winrt::Windows::Graphics::DirectX::DirectXPixelFormat &)': cannot convert argument 2 from 'winrt::array_view<const uint8_t>' to 'const winrt::Windows::Storage::Streams::IBuffer &' (compiling source file MainWindow.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\MainWindow.xaml.h(47,31): message : Reason: cannot convert from 'winrt::array_view<const uint8_t>' to 'const winrt::Windows::Storage::Streams::IBuffer' (compiling source file MainWindow.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\MainWindow.xaml.h(47,31): message : No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called (compiling source file MainWindow.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\Generated Files\winrt\Microsoft.Graphics.Canvas.h(4272,31): message : or 'winrt::Microsoft::Graphics::Canvas::CanvasBitmap winrt::Microsoft::Graphics::Canvas::CanvasBitmap::CreateFromBytes(const winrt::Microsoft::Graphics::Canvas::ICanvasResourceCreator &,winrt::array_view<const uint8_t>,int32_t,int32_t,const winrt::Windows::Graphics::DirectX::DirectXPixelFormat &)' (compiling source file MainWindow.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\MainWindow.xaml.h(46,60): message : 'winrt::Microsoft::Graphics::Canvas::CanvasBitmap winrt::Microsoft::Graphics::Canvas::CanvasBitmap::CreateFromBytes(const winrt::Microsoft::Graphics::Canvas::ICanvasResourceCreator &,winrt::array_view<const uint8_t>,int32_t,int32_t,const winrt::Windows::Graphics::DirectX::DirectXPixelFormat &)': cannot convert argument 5 from 'const winrt::Microsoft::Graphics::DirectX::DirectXPixelFormat' to 'const winrt::Windows::Graphics::DirectX::DirectXPixelFormat &' (compiling source file MainWindow.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\MainWindow.xaml.h(48,33): message : Reason: cannot convert from 'const winrt::Microsoft::Graphics::DirectX::DirectXPixelFormat' to 'const winrt::Windows::Graphics::DirectX::DirectXPixelFormat' (compiling source file MainWindow.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\MainWindow.xaml.h(48,33): message : Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or parenthesized function-style cast) (compiling source file MainWindow.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\MainWindow.xaml.h(46,60): message : while trying to match the argument list '(const winrt::Microsoft::Graphics::Canvas::ICanvasResourceCreator, winrt::array_view<const uint8_t>, int, int, const winrt::Microsoft::Graphics::DirectX::DirectXPixelFormat)' (compiling source file MainWindow.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\MainWindow.xaml.h(46,60): error C2665: 'winrt::Microsoft::Graphics::Canvas::CanvasBitmap::CreateFromBytes': no overloaded function could convert all the argument types (compiling source file App.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\Generated Files\winrt\Microsoft.Graphics.Canvas.h(4284,31): message : could be 'winrt::Microsoft::Graphics::Canvas::CanvasBitmap winrt::Microsoft::Graphics::Canvas::CanvasBitmap::CreateFromBytes(const winrt::Microsoft::Graphics::Canvas::ICanvasResourceCreator &,const winrt::Windows::Storage::Streams::IBuffer &,int32_t,int32_t,const winrt::Windows::Graphics::DirectX::DirectXPixelFormat &)' (compiling source file App.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\MainWindow.xaml.h(46,60): message : 'winrt::Microsoft::Graphics::Canvas::CanvasBitmap winrt::Microsoft::Graphics::Canvas::CanvasBitmap::CreateFromBytes(const winrt::Microsoft::Graphics::Canvas::ICanvasResourceCreator &,const winrt::Windows::Storage::Streams::IBuffer &,int32_t,int32_t,const winrt::Windows::Graphics::DirectX::DirectXPixelFormat &)': cannot convert argument 2 from 'winrt::array_view<const uint8_t>' to 'const winrt::Windows::Storage::Streams::IBuffer &' (compiling source file App.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\MainWindow.xaml.h(47,31): message : Reason: cannot convert from 'winrt::array_view<const uint8_t>' to 'const winrt::Windows::Storage::Streams::IBuffer' (compiling source file App.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\MainWindow.xaml.h(47,31): message : No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called (compiling source file App.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\Generated Files\winrt\Microsoft.Graphics.Canvas.h(4272,31): message : or 'winrt::Microsoft::Graphics::Canvas::CanvasBitmap winrt::Microsoft::Graphics::Canvas::CanvasBitmap::CreateFromBytes(const winrt::Microsoft::Graphics::Canvas::ICanvasResourceCreator &,winrt::array_view<const uint8_t>,int32_t,int32_t,const winrt::Windows::Graphics::DirectX::DirectXPixelFormat &)' (compiling source file App.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\MainWindow.xaml.h(46,60): message : 'winrt::Microsoft::Graphics::Canvas::CanvasBitmap winrt::Microsoft::Graphics::Canvas::CanvasBitmap::CreateFromBytes(const winrt::Microsoft::Graphics::Canvas::ICanvasResourceCreator &,winrt::array_view<const uint8_t>,int32_t,int32_t,const winrt::Windows::Graphics::DirectX::DirectXPixelFormat &)': cannot convert argument 5 from 'const winrt::Microsoft::Graphics::DirectX::DirectXPixelFormat' to 'const winrt::Windows::Graphics::DirectX::DirectXPixelFormat &' (compiling source file App.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\MainWindow.xaml.h(48,33): message : Reason: cannot convert from 'const winrt::Microsoft::Graphics::DirectX::DirectXPixelFormat' to 'const winrt::Windows::Graphics::DirectX::DirectXPixelFormat' (compiling source file App.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\MainWindow.xaml.h(48,33): message : Conversion to enumeration type requires an explicit cast (static_cast, C-style cast or parenthesized function-style cast) (compiling source file App.xaml.cpp)
1>C:\Users\user\Win2DIssue\Example\MainWindow.xaml.h(46,60): message : while trying to match the argument list '(const winrt::Microsoft::Graphics::Canvas::ICanvasResourceCreator, winrt::array_view<const uint8_t>, int, int, const winrt::Microsoft::Graphics::DirectX::DirectXPixelFormat)' (compiling source file App.xaml.cpp)
Any idea why the polymorphism seems to fail in this case? The functions seem to be correctly defined under Microsoft.Graphics.Canvas.h .
The workaround is to convert explicitly format to (winrt::Windows::Graphics::DirectX::DirectXPixelFormat const&) when calling the function.
The text was updated successfully, but these errors were encountered:
cosmin42
changed the title
Unusable Microsoft::Graphics::Canvas::CanvasBitmap::CreateFromBytes (cannot build)
Somthing is wrong with Microsoft::Graphics::Canvas::CanvasBitmap::CreateFromBytes (not straight forward to call it)
Sep 17, 2023
I managed to isolate this problem into a simple project: https://github.com/cosmin42/Win2DIssue
Using the CreateFromBytes static method in the below function seems to be impossible to build as it asks for
array_view
when passingIBuffer
and then asking forarray_view
when passingIBuffer
.The build error:
Any idea why the polymorphism seems to fail in this case? The functions seem to be correctly defined under
Microsoft.Graphics.Canvas.h
.The workaround is to convert explicitly format to (winrt::Windows::Graphics::DirectX::DirectXPixelFormat const&) when calling the function.
The text was updated successfully, but these errors were encountered: