iOS Question LoadBitmapResize image is blurred if the image scale down

Alexander Stolte

Expert
Licensed User
Longtime User
Hello,

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.
B4X:
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.
 

Attachments

  • LoadBitmapResize Bug.zip
    16.4 KB · Views: 256

Erel

B4X founder
Staff member
Licensed User
Longtime 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:
B4X:
Dim scale As Float = GetDeviceLayoutValues.NonnormalizedScale
ImageView1.Bitmap = LoadBitmapResize(File.DirAssets,"newest_filled.png",ImageView1.Width * scale,ImageView1.Height * scale,True)
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Because i'm lazy:
B4X:
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
 
Upvote 0
Top