iOS Question LoadBitmapResize image is blurred if the image scale down

Discussion in 'iOS Questions' started by Alexander Stolte, Dec 4, 2018.

  1. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User


    i have a problem with LoadBitmapResize, it is recommended to use it, but i have this strange output:

    Left is the icon with "LoadBitmap" and right it is load with "LoadBitmapResize"
    IMG_0062.jpg IMG_0063.jpg
    The Icon is 100x100.
    I use the width and height of the imageview.
    ImageView1.Bitmap = LoadBitmapResize(File.DirAssets,"newest_filled.png",ImageView1.Width,ImageView1.Height,True)
    Why is that so? In B4A this icon looks good with LoadBitmapResize, it is the same code.
    In the attachment is a sample project to demonstrate it.

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    Moved to the questions forum.

    The bitmap returned has a scale of 1.0. This is lower than your device scale. You will get a sharp image by creating a larger image based on the device scale:
    Dim scale As Float = GetDeviceLayoutValues.NonnormalizedScale
    ImageView1.Bitmap = LoadBitmapResize(
    File.DirAssets,"newest_filled.png",ImageView1.Width * scale,ImageView1.Height * scale,True)
    Alexander Stolte likes this.
  3. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    Because i'm lazy:
    Public Sub LoadBitmapResize2(Dir As String,FileName As String,Width As Int, height As Int,KeepAspectRatio As Boolean) As B4XBitmap
    #If B4A
    Return LoadBitmapResize(Dir,FileName,Width,height,KeepAspectRatio)
    #Else IF B4I
    Dim scale As Float = GetDeviceLayoutValues.NonnormalizedScale
    Return     LoadBitmapResize(Dir,FileName,Width  * scale,height  * scale,KeepAspectRatio)
    #End If
    End Sub
    Erel likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice