This Project was based on Windows10 IoTCore "Hello World"Damo.I Want to show Image by pure rgb bytes array.So I added my code in this.
public async void Func()
{
int ret;
uint mode, x, y, width, height;
mode = x = y = width = height = 0;
ret = Roseek_ImageAcquisition_GetResolution(ref mode, ref x, ref y, ref width, ref height);
RunFlag = true;
uint buffsize = width * height * 3;
RawFrameInfo frameinfo = new RawFrameInfo();
byte[] Framebytes = new byte[buffsize];
byte[] bgra = new byte[width * height * 4];
while (RunFlag)
{
ret = Roseek_ImageAcquisition_FetchFrame(Framebytes, buffsize, ref frameinfo, 1000);
if (ret == 0)
{
pFrameToRGB(Framebytes, bgra, (int)width, (int)height);
/* IBuffer ibuf = new Windows.Storage.Streams.Buffer(width * height * 4);
bgra.CopyTo(ibuf);
SoftwareBitmap image = SoftwareBitmap.CreateCopyFromBuffer(ibuf, BitmapPixelFormat.Bgra8, (int)width, (int)height, BitmapAlphaMode.Ignore);
SoftwareBitmapSource sf = new SoftwareBitmapSource();
await sf.SetBitmapAsync(image);*/
using (IRandomAccessStream RandomAccessStream = new InMemoryRandomAccessStream())
{
BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.BmpEncoderId, RandomAccessStream);
encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Ignore, width, height, 96, 96, bgra);
await encoder.FlushAsync();
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, async () =>
{
var image = new BitmapImage();
await image.SetSourceAsync(RandomAccessStream);
}) ;
}
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
{
HelloMessage.Text = "While Loop! FetchFrame OK!";
});
}
}
Some "Roseek" functions are from another DLLs. I think that some wrong codes may be added in while Loop. I debuged this App many times and it's OK. When I modified and continue to remote debuge this App ,some sample err like “Memery out" happened.After that,I can't active App forever, but App was installed in IoT device. I try what i can do like restart or uninstalling App,but not work. I'm a green hand about developing UWP on IoTCore. So can I ask that some wrong code I added in loop?
I get the very same error when using VS2017 / Xamarin whatEver template & UWP The app loads to the phone and then it crashes. So I would say that there is nothing wrong with your code. Winphones are not supported anymore by MS ;)
On my not supported Winphone restarting it made it working again
User contributions licensed under CC BY-SA 3.0