iOS Question Image is stretched

Lucas Eduardo

Active Member
Licensed User

Attachments

  • 1.jpeg
    1.jpeg
    67.2 KB · Views: 249

Lucas Eduardo

Active Member
Licensed User
In the screenshot there is not image blurred because i use this code, but the image it's stretched
B4X:
Dim scale As Float = GetDeviceLayoutValues.NonnormalizedScale
ivImagem.Bitmap = LoadBitmapResize(pastaImagem,nomeImagem,ivImagem.Width * scale,ivImagem.Height * scale,False)
but in the thread https://www.b4x.com/android/forum/t...-fit-images-without-distortion.86627/#content i tryed both of them
B4X:
Sub FitImageToView(bmp As B4XBitmap, ImageView As B4XView)
and this
B4X:
Sub FillImageToView(bmp As B4XBitmap, ImageView As B4XView)

And both of them keeps the images blurred
 
Upvote 0

Lucas Eduardo

Active Member
Licensed User
I was doing an example to show to you and i tryed to put one sub after another and the results are good. Is it the best way to get it?
B4X:
FitImageToView(bt2, ImageView1)
Ajusta_Imagem1(ImageView1, File.DirAssets, "image2.png")

B4X:
Public Sub Ajusta_Imagem1(ivImagem As ImageView,pastaImagem As String,nomeImagem As String)
    #IF B4A
    ivImagem.SetBackgroundImage(XUI.LoadBitmapResize(pastaImagem, nomeImagem, ivImagem.Width, ivImagem.Height, True)).Gravity = Gravity.CENTER
    #ELSE IF B4I
    Dim scale As Float = GetDeviceLayoutValues.NonnormalizedScale
    ivImagem.Bitmap = LoadBitmapResize(pastaImagem,nomeImagem,ivImagem.Width * scale,ivImagem.Height * scale,True)
    #End If
End Sub
 

Attachments

  • exampleImage.zip
    13.5 KB · Views: 240
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
As I understood, you crop a picture (enough unusual way).
It's possible to replace imageview by panel with imageview as child (see sample).
 

Attachments

  • image.zip
    11.7 KB · Views: 230
Upvote 0

Lucas Eduardo

Active Member
Licensed User
It's cropping the images when they are small
B4X:
Dim bmp As B4XBitmap = XUI.LoadBitmap(File.DirAssets, "iconSairMenu.png")
utils.FillImageToView(bmp, iconMenuLateral)
 

Attachments

  • crop.png
    crop.png
    196.3 KB · Views: 223
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Even so old models as iPhone 7, 8 Plus have width 1242 pixels. it looks that a picture in side menu is about 40% of width (approx. 500 pixels * 500 pixels).
Which size has a png-file ? Guess, that much less, so IOS really "stretches" and a picture on the screen looks terrible.
Use SVG file (if possible).
 
Upvote 0
Top