Spanish achicar foto png

Discussion in 'Spanish Forum' started by mvera, Aug 17, 2015.

  1. mvera

    mvera Active Member Licensed User

    hola tengo un programa que toma fotografías y la pasa al teléfono , el problema que tengo es que pesan 2.5 megas demasiado , necesito bajarlas de tamaño, encontré una librería llamada RSImageProcessing pero no se como ocuparla.
    Espero que alguien pueda orientarme.
    gracias.

    codigo fuente.

    'Activity module
    Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

    End Sub

    Sub Globals
    Dim camera1 As Camera
    Dim btnTakePicture As Button
    Dim Panel1 As Panel
    'Dim r As RSImageProcessing
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    End Sub
    Sub Camera1_Ready (Success As Boolean)
    If Success Then
    camera1.StartPreview
    btnTakePicture.Enabled = True
    Else
    ToastMessageShow("Cannot open camera.", True)
    End If
    End Sub

    Sub Activity_Resume
    btnTakePicture.Enabled = False
    camera1.Initialize(Panel1, "Camera1")

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)
    camera1.Release
    End Sub

    Sub Camera1_PictureTaken (Data() As Byte)
    camera1.StartPreview
    Dim out As OutputStream
    out = File.OpenOutput(File.DirRootExternal, "/seguridad/1.jpg", False)

    out.WriteBytes(Data, 0, Data.Length)
    out.Close
    ToastMessageShow("Image saved: " & File.Combine(File.DirRootExternal, "1.jpg"), True)
    btnTakePicture.Enabled = True
    End Sub


    'funcion que no se como aplicarla.
    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



    Sub btnTakePicture_Click
    btnTakePicture.Enabled = False
    camera1.TakePicture
    End Sub
     
  2. eurojam

    eurojam Well-Known Member Licensed User

    Hola,
    creo es algo como lo siguente (pero sin test):
    Code:
    Sub Camera1_PictureTaken (Data() As Byte)
        camera1.StartPreview
        
    Dim out As OutputStream
        out = 
    File.OpenOutput(File.DirRootExternal, "/seguridad/1.jpg"False)
        
    Dim b, bs As Bitmap
        out.WriteBytes(Data, 
    0, Data.Length)
        out.Close
        
    ToastMessageShow("Image saved: " & File.Combine(File.DirRootExternal, "1.jpg"), True)
        b.Initialize(
    File.DirRootExternal, "1.jpg")
        bs = ReSize(b,
    100,100)
        out = 
    File.OpenOutput(File.DirRootExternal,"1_resize.jpg",False)
        bs.WriteToStream(out,
    100,"JPG"
        btnTakePicture.Enabled = 
    True
    End Sub
    stefan
     
  3. mvera

    mvera Active Member Licensed User

    muchas gracias lo probare.
     
  4. mvera

    mvera Active Member Licensed User

    primero stefan gracias por tu gran ayuda.

    puede hacer funcionar tu código pero me encontré con un error que no puedo manejar bien.
    Carga el programa saco la foto y me da el siguiente error.

    java.lang.IllegalArgumentException: bitmap size exceeds 32bits


    El error esta en esta funcion.

    Sub ReSize(b As Bitmap, newWidth As Int, newHeight As Int) As Bitmap
    Dim r As RSImageProcessing
    Return r.scaleBitmap(b, newWidth, newHeight) En esta linea marca el error.
    End Sub
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice