Android Question resize bitmap to a specific size

stp

Active Member
Licensed User
Longtime User
i have a bitmap
B4X:
img.Bitmap = Base64EncodeDecodeImage.Base64StringToImage(kont)

i can handle my img.Bitmap that is an png or webp image
now i want to resize that img.Bitmap which is now 400x400 to eg 100x100
how can i do that ?
Thank you
 

DonManfred

Expert
Licensed User
Longtime User
Save your bitmap to a file and then use loadbitmapresize

 
Upvote 0

stp

Active Member
Licensed User
Longtime User
Save your bitmap to a file and then use loadbitmapresize

Yes i know that, but i don't want to save to file. Why should i do that? I have the data img.Bitmap, is there no other solution ?
 
Upvote 0

valerioup

Member
Licensed User
Longtime User
Yes i know that, but i don't want to save to file. Why should i do that? I have the data img.Bitmap, is there no other solution ?
sample:
    Dim bmp As Bitmap = Base64EncodeDecodeImage.Base64StringToImage(kont)

    Dim newW As Int = 100
    Dim newH As Int = 100

    Dim resized As Bitmap
    resized.InitializeMutable(newW, newH)

    Dim cvs As Canvas
    cvs.Initialize2(resized)
    cvs.DrawBitmap(bmp, Null, cvs.TargetRect)
img.Bitmap=resized

Using the canvas, you can resize without going to a file. To be tested.
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Did you try
B4X:
img.Bitmap = Base64EncodeDecodeImage.Base64StringToImage(kont).Resize(100, 100, True)
 
Last edited:
Upvote 0
Top