Android Question Macroscopic difference in creating images

AlpVir

Well-Known Member
Licensed User
Longtime User
I attached 2 thumbnail PNG images created with the exact same code, a emulator and a physical device.
Unfortunately, the image created by the emulator is essentially correct and that created by the physical device is grossly incorrect.
I have no idea to explain this difference.
The original images are both of 1200x1200 pixels and each of 1442401 points is written with the statement Canvas.DrawPoint (CX, CY, Colore) in a For-Next loop.
What could I have your suggestion to solve the problem ?
Thank you for your attention.
 

Attachments

  • N44E007_emulator.png
    N44E007_emulator.png
    138.1 KB · Views: 239
  • N44E007_device.png
    N44E007_device.png
    134.5 KB · Views: 261

AlpVir

Well-Known Member
Licensed User
Longtime User
Indeed, the problem arose from the test IF H<MaxAltezza
As the files to be examined are those in Europe and Europe is the maximum altitude of Monte Bianco (4810 m) I thought to exclude any errors in the file with this simple test.
Unfortunately, errors in the file are more than one and this causes the distortion.
It remains the big mystery of why, with the emulator, the picture was not distorted: I checked again just now.
Perhaps in this case also has reason Straker and depends on how the physical device end then emulator treat the bytes.
Thank you so much for your patience !
 
Upvote 0

Straker

Active Member
Licensed User
Longtime User
Well, I don't think it's a big mistery...
I Think that the emulator is running with a PC (Little Endian) and the device is a Big Endian.
Probably the simplest solution is to invert the two bytes.
Original code:
B4X:
B1=buffer(i) : B2=buffer(i+1) : H=Bit.AND(B1, 255)*256+Bit.AND(B2, 255)

Try this (B1 and B2 are inverted):
B4X:
B2=buffer(i) : B1=buffer(i+1) : H=Bit.AND(B1, 255)*256+Bit.AND(B2, 255)

If what I think is correct, you'll have a distorted image on the emulator and a vaid one on the device...
 
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
According to me the mystery remains in what I already do I make an exchange. Byte but not the color.
ColoreX = Colors.RGB (B, G, R)
and not
ColoreX = Colors.RGB (R, G, B)
I reiterate that the code is always the same, emulator or physical device.
For the pair of bytes number 2830 the 3 following instructions
B1 = buffer (s) : B2 = buffer (i + 1) : H = Bit.AND (B1, 255) * 256 + Bit.AND (B2, 255)
produced to smartphone
B1 = -128
B2 = 0
H = 32768
and to emulator
B1 = 6
B2 = -10
H = 1768
 
Upvote 0

Straker

Active Member
Licensed User
Longtime User
Can you read the first 10 or 20 bytes and give me those values. I'll check the value against the file you linked (N44E007.hgt)
 
Upvote 0

Straker

Active Member
Licensed User
Longtime User
Ok, I've done some test. These are the results:

_MyCode.jpg
_YourCode.jpg


I read your file and plotted the pixels, using fake colors (I didn't know your transformations...)
The first image (on the left side) is made using my code.
The other, on the right side, is made with your code.
 
Upvote 0

AlpVir

Well-Known Member
Licensed User
Longtime User
I apologize. The difference in reading byte (post #23) between emulator and physical device was solely due to a different version of the file HGT.
In other words, the two HGT file processed (on the emulator and on the smartphone) by me had a different origin and then some small difference.
At this point, correct the error identified by you to post # 20, everything is OK. Tanks very much !
N44E007_gm.jpg
N44E007_app.jpg

Below I report the current output of the app (right) and the output of a professional software (left)
I still have to study all false colors to achieve that result.
 
Upvote 0
Top