I understood what happens:
My images are 720 x 1280 and the phones that have the same ratio see the image in full.
Phones that do not have the same ratio see a black strip on the side because Errel's code keep the ratio in priority.
So three things possible if the phone does not have the same ratio:
- Either put the image centered with transparency => bad
- Or put the picture size by deforming slightly (fit) => maybe the best way
- Either cut the image and zoom
How to code after it is another thing
I'm right because the Nexus is not a 720 x 1280 phone but in reality is 720 x 1184 !!!
Look at this :
Dim origRatio As Float = original.Width / original.Height
Log ("OrigineRation : " & origRatio)
Dim targetRatio As Float = TargetX / TargetY
Log(TargetX & " - " & TargetY)
Log ("TargetRation : " & targetRatio)
Dim scale As Float
Errel take a target ratio 1280 x 1280
look the log
For my Samsung SIII
OrigineRation : 0.5625
1280 x 1280
TargetRation : 1
For your Nexus :
1340 - 1196
TargetRation : 1.120401382446289
the only thing to do is get as close as possible of the ratio and fit image width and height maximum like we do in photoshop for exemple