Android Question how to resize file image

Markos

Active Member
Licensed User
Longtime User
Hi All,

Is there a library to permit changing the size (width and height) of an image file be it from data array or a file say in jpeg format
 

Markos

Active Member
Licensed User
Longtime User
Cheers Erel!

using a bitmap object would the Resize function achieve the result of resizing the bitmap a code snippet shown below
bitmap resize and save as jpg:
        Dim bmpnew0 As Bitmap
        Dim bmpnew As Bitmap

        bmpnew0 = LoadBitmap(File.DirAssets, "SomeFile.jpg"))
        bmpnew=bmpnew0.Resize(320,240,True)
        out = File.OpenOutput(File.DirInternal, "tmpfile2.jpg", False)
        bmpnew.WriteToStream(out, 100, "JPEG")
 
Last edited:
Upvote 0

Markos

Active Member
Licensed User
Longtime User
Better to use XUI.LoadBitmapResize.

1. It is cross platform.
2. It most cases it will not load the full image to memory, which can result in out of memory issues with very large images.
Many thanks Erel I will utilise your suggestion as primary given your insight. Although for images 3mb or less it seems to work well using the previous method
 
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Or use Thumbnailator. Has many useful features.
I see this is a library for B4J; the question here is about B4A, and it MAYBE wouldn't handle very large images well (but since it's for B4J - Desktop, that shouldn't be a problem).

Interestingly:
Work on UI/Non-UI/Server applications.

I didn't know about it, thanks for the link, @tchart
 
Upvote 0
Top