Android Question Pixelated Image after resizing

Fusseldieb

Active Member
Licensed User
Longtime User
Hi all,
when I try to upsize a image with Canvas, it gives me a totally pixelated image, instead of interpolating it...
Screenshot_2015_01_11_08_26_25_1.png

Is there any function or library to turn interpolating on?

Thanks in advance :)

(Sorry for the huge image. It was taken directly from my cellphone)
 

Fusseldieb

Active Member
Licensed User
Longtime User
For those who search for this too, here is the answer...
Use the code below:
B4X:
Sub SetAntiAlias (c3 As Canvas)
   Dim r As Reflector
   Dim NativeCanvas As Object
   r.Target = c3
   NativeCanvas = r.GetField("canvas")
   Dim PaintFlagsDrawFilter As Object
   PaintFlagsDrawFilter = r.CreateObject2("android.graphics.PaintFlagsDrawFilter", _
Array As Object(0, 2), Array As String("java.lang.int", "java.lang.int"))

   r.Target = NativeCanvas
   r.RunMethod4("setDrawFilter", Array As Object(PaintFlagsDrawFilter), Array As String("android.graphics.DrawFilter"))
End Sub

In Array As Object(0, 2), the number must be set to 2 for antialiasing Bitmaps.
Other things, such as lines should be working with 1.

For those who are confused: We use this code after initializing the canvas;)

Like so:
B4X:
Canvas1.Initialize(Activity)
SetAntiAlias(Canvas1)
'Here you draw all your bitmaps and things...

A huge thanks to @LucaMs :D
 
Upvote 0
Top