Found some strange dart interface #383
-
I'm coping some cpp codes into dart this is the source cpp codes: BYTE* lp = r.lpbitmap;
InMemoryRandomAccessStream stream;
DataWriter dataWriter{stream};
dataWriter.WriteBytes(array_view<byte>(lp, r.dwBmpSize));
auto buffer = dataWriter.DetachBuffer(); this is what I write using dartwinrt final List<int> bytes = ...;
final stream = InMemoryRandomAccessStream();
final DataWriter dataWriter = DataWriter.createDataWriter(stream);
dataWriter.writeBytes(bytes);
final buffer = dataWriter.detachBuffer(); I wonder could I use something like And why |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
No, you can't (and you likely meant
This project is designed to provide an idiomatic Dart projection of the WinRT APIs, which involves substantial wrapping. For the sake of idiomatic usage, the method doesn't take a parameter like |
Beta Was this translation helpful? Give feedback.
-
OK, and I find I can directly use This function can easily convert final dwBmpSize = 1000;
final Pointer<Uint8> lpBitmap = arena<Uint8>(dwBmpSize);
final Uint8List bytes = lpBitmap.asTypedList(dwBmpSize);
// ...
dataWriter.writeBytes(bytes); |
Beta Was this translation helpful? Give feedback.
No, you can't (and you likely meant
Pointer<Uint8>
instead ofPointer<List<int>>
, as the latter is not a valid Dart type).This project is designed to provide an idiomatic Dart projection of the WinRT APIs, which involves substantial wrapping. For the sake of idiomatic usage, the method doesn't take a parameter like
Pointer<Uint8>
; instead, it acceptsList<int>
, which serves as the equivalent counterpart.