May 27, 2020 Code: Copy SavePictureToFile(XUIImageToJPEGByteArray(CreateThumbnail(xui.LoadBitmapResize(File.DirAssets,"Snapchat-248558753.jpg",150dip,150dip,True)),150dip,150dip,50),File.DirRootExternal,"test.jpg") "quality" on "XUIImageToJPEGByteArray" results on a: 910kb image quality = 50 = 17,69KB quality = 100 = 100KB Code: Copy Public Sub SavePictureToFile(Data() As Byte, Dir As String, FileName As String) Dim out As OutputStream = File.OpenOutput(Dir, FileName, False) out.WriteBytes(Data, 0, Data.Length) out.Close End Sub XUIImageToJPEGByteArray: [B4X][XUI] Image to JPEG byte array with resize/quality options Originally posted a B4J/inline Java version of this in the B4J Code Snippets (https://www.b4x.com/android/forum/threads/image-to-jpeg-byte-array-with-resize-quality-options.91746/). @Erel pointed out though that the XUI library had the functionality that I was doing with Java, so I decided to... www.b4x.com [B4X] Create square Thumbnail Sub CreateSquareThumbnail(Input As B4XBitmap) As B4XBitmap If Input.Width Input.Height Then 'if the image is not square then we crop it to be a square. Dim l As Int = Min(Input.Width, Input.Height) Return Input.Crop(Input.Width / 2 - l / 2, Input.Height / 2 - l / 2... www.b4x.com Click to expand...
Code: Copy SavePictureToFile(XUIImageToJPEGByteArray(CreateThumbnail(xui.LoadBitmapResize(File.DirAssets,"Snapchat-248558753.jpg",150dip,150dip,True)),150dip,150dip,50),File.DirRootExternal,"test.jpg") "quality" on "XUIImageToJPEGByteArray" results on a: 910kb image quality = 50 = 17,69KB quality = 100 = 100KB Code: Copy Public Sub SavePictureToFile(Data() As Byte, Dir As String, FileName As String) Dim out As OutputStream = File.OpenOutput(Dir, FileName, False) out.WriteBytes(Data, 0, Data.Length) out.Close End Sub XUIImageToJPEGByteArray: [B4X][XUI] Image to JPEG byte array with resize/quality options Originally posted a B4J/inline Java version of this in the B4J Code Snippets (https://www.b4x.com/android/forum/threads/image-to-jpeg-byte-array-with-resize-quality-options.91746/). @Erel pointed out though that the XUI library had the functionality that I was doing with Java, so I decided to... www.b4x.com [B4X] Create square Thumbnail Sub CreateSquareThumbnail(Input As B4XBitmap) As B4XBitmap If Input.Width Input.Height Then 'if the image is not square then we crop it to be a square. Dim l As Int = Min(Input.Width, Input.Height) Return Input.Crop(Input.Width / 2 - l / 2, Input.Height / 2 - l / 2... www.b4x.com