Android Question Difficulty converting bytes to images

Hi

Erel had previously installed a CCTV source:
I edited these sources for further practice so that images from one client are sent in bytes to the server and from the server are sent to another client, and in another client the bytes are converted to images and in an image view to Live faces are displayed.
But the problem is that the bytes do not convert to the image properly and turn green, blue and red on the image.

I even ran Source Erel without tampering, and the images were the same on the b4j.
To further investigate the problem, I created an empty project for Android and inserted an image view, and the image was received from the phone's camera and converted to bytes, and I converted the bytes to the image again and displayed an image view on the same phone. But it was still a problem.
I came to the conclusion that the problem is not with the server and nothing happens in the client-to-server path for the data.
Either the image may not be converted to byte properly or the byte may not be converted to image properly.
To understand more, I leave a screenshot:
Screenshot_۲۰۲۱۰۸۲۸-۱۸۵۰۵۰.jpg

The image on the right is the result of converting bytes received from another phone's camera, but the received image displayed in the image view is not clear.
What is the problem and how can I fix it?
Please give full guidance. Thanks to Erel and the rest of the developers
 

MikeSW17

Active Member
Licensed User
Longtime User
The second image looks like the image width is not being handled properly. Each display 'line' seems wrapped onto the next line, causing the 'slanted' pattern.
What are the resolutions and frame rates of the two cameras?
I've no idea what you can do in B4A for this (experts will be along soon) ;) . But I expect if the resolution of the two cameras can be made the same, it will work.
 
Upvote 0
The second image looks like the image width is not being handled properly. Each display 'line' seems wrapped onto the next line, causing the 'slanted' pattern.
What are the resolutions and frame rates of the two cameras?
I've no idea what you can do in B4A for this (experts will be along soon) ;) . But I expect if the resolution of the two cameras can be made the same, it will work.
The camera resolution is 13 megapixels. I tried on 2 to 48 megapixels on several devices, but they are all the same. How do I manage the width of the image properly and how do I prevent the "slanted" pattern from being created?
Thank you very much for your answer. I wish Erel would give an answer too
 
Upvote 0
I can't because you haven't provided enough information. I guess that you aren't handling the preview data correctly and assume that you can treat it as a Bitmap. It won't work.

Post the relevant code.
Thank you for your answer. I was able to solve the problem myself using the following source:
 
Upvote 0
Top