in my project i need to save a compressed image file from a large one to make it easy for upload.
i tried this code :
B4X:
Dim btmp As Bitmap
btmp.Initialize(File.DirRootExternal & "/picture",FileName)
Dim Out As OutputStream
Out = File.OpenOutput(File.DirRootExternal &"/picture", "Test.png", False)
btmp.Resize(btmp.Width/5,btmp.Height/5,True).WriteToStream(Out, 50, "PNG")
Out.Close
the new image ( document ) is not readable even if its size can be up to 100 Ko. any help please ?
This tutorial explains the differences between the three methods. The bottom line is that the best option is to use LoadBitmapResize and set the container gravity, if possible, to Gravity.CENTER. LoadBitmap - Simply loads the bitmap as-is. Loading unknown bitmap files with LoadBitmap is...
This code is no longer needed. Use File.WriteBytes / ReadBytes. Write an array of bytes to a file and read a file into an array of bytes. Sub BytesToFile (Dir As String, FileName As String, Data() As Byte) Dim out As OutputStream = File.OpenOutput(Dir, FileName, False)...