Closed delphi007 closed 2 years ago
Like the readme say, Mjpeg.width, MJpeg.height are to force the size of the widget. I don't care about the original size of the image so I don't have it anywhere. No even sure how to get it.
OK, thanks. I have found the workaround, in case anyone who need the width & height.
latestImg = image.value;
The above line should be put right after
if (image.value == null) { ... }
_mjpeg?.latestImg
?.resolve(ImageConfiguration())
.addListener(
ImageStreamListener((ImageInfo info, bool _) {
final imgWidth = info.image.width;
final imgHeight = info.image.height;
... //Do other stuff as you like
}));
I am using this plugin to show phone screen stream and need to perform action on the screen. So the width & height is a must to calculate relative ratio for interaction. And the screen orientation could change during the streaming, so that's why I need the realtime width & height. To avoid calculation for each frame. I decided to just save the RawImage for future use and leave the calculation when needed.
Sorry for not clarifying the usage scenario. I agree it's not a necessary function for this widget. Still share my solution for anyone who is interested.
Thank you for this great widget. It's working fine.
Work around found.
nice thanks for sharing. If I may, using build method to populate a field that you used in the app is not a good/clean approach.
One way to do it is to add a callback as parameter on Mjpeg widget where you pass the current MemoryImage
each time it changes. This way the widget is telling you when a new image is present and it's not you who check a field of the widget.
If you want to do a PR in that way so you don't have to fork this package please do, I'll be happy to merge it :)
I have run this widget well in my project. I need the original width / height of jpeg image. But when I access Mjpeg.width, MJpeg.height, they are always null.
What should I do to retrieve the Size for image?