0

Hello at this time camera capturing image size is more than 1 mb. I want to reduce it to 20kb. Please help me.

Sub Camera1_PictureTaken (Data() As Byte)
    camera1.StartPreview
    DateTime.DateFormat ="HH.mm.ss.SS_dd-MM-yy_"
    forDate=DateTime.Date(DateTime.now)
    imei = pID.GetDeviceId

    filename = forDate & imei& "_.jpeg"
    File.MakeDir(File.DirRootExternal,"/data/data/a3a/cam/update/images")
    out = File.OpenOutput(File.DirRootExternal,"/data/data/a3a/cam/update/images/"&filename, False)
    out.WriteBytes(Data, 0, Data.Length)
    out.Close
End Sub
ching lee
  • 11
  • 7

2 Answers2

1

Approach without library:

Sub UploadImage(Dir As String, Filename As String) As Byte()
    Dim Image As Bitmap = LoadBitmapSample(Dir, Filename, 1920, 1080)
    Dim Out As OutputStream
    Out.InitializeToBytesArray(100)
    Image.WriteToStream(Out, 90, "JPEG")
    Return Out.ToBytesArray
End Sub
Daniel Jäger
  • 177
  • 1
  • 3
  • 13
0

You can add RSImageProcessing library to your project.

This code will be bright your mind :)

Sub ReSize(b As Bitmap, newWidth As Int, newHeight As Int) As Bitmap
   Dim r As RSImageProcessing
   Return r.scaleBitmap(b, newWidth, newHeight)
End Sub
Serhat MERCAN
  • 1,078
  • 3
  • 14
  • 31