afriscic / BarcodeScanning.Native.Maui

Barcode scanning library for .NET MAUI
https://www.nuget.org/packages/BarcodeScanning.Native.Maui
MIT License
183 stars 33 forks source link

No image detail when exporting the image using CaptureAsync() #46

Closed PeterTaylorTX closed 7 months ago

PeterTaylorTX commented 7 months ago

I'm trying to export the image after the barcodes are detected so I can save the image for logging.

I am running the following code to get the Byte[] of the image.

MemoryStream mStream = new();
IScreenshotResult rawImage = await this.BarcodeView.CaptureAsync();
await rawImage.CopyToAsync(mStream, ScreenshotFormat.Jpeg, 100);
Byte[] SourceImage = mStream.ToArray();

However, when the Byte[] array is saved to the device the image is a black jpg with no detail. The image resolution is correct, just no image data. Inspecting the returned byte[] shows that most of the bytes are showing the value of 0.

Nuget Version: 1.4.1 OS: Android 14 Testing Device: Samsung Galaxy S21

Thank you in advance, Pete

afriscic commented 7 months ago

Hello.

Direct image capture is currently unsupported as the main focus of this repository was continuous scanning and image capture requires a lot of processing which would slow capture rate down. I can put it on a TODO list but I would need time to figure out a way to integrate it without interfering with current functionality and performance.

Maybe MAUI integrated screenshot feature would be leasable alternative for you.

PeterTaylorTX commented 7 months ago

The export of the image would not be needed after every barcode detection, just on request, usually as the camera screen is closing and detecting is already paused.

If you could please add an option to get a copy of the image byte[] on request/command to the roadmap that would be very helpful.

Thank you Pete