Android Question Crop image.jpg

Discussion in 'Android Questions' started by Devv, Jun 23, 2015.

  1. Devv

    Devv Active Member Licensed User

    How could i crop an image file on the sdcard ?
    i want fixed size, 10% from the height and 100 of width
    how to do so without user interaction or GUI ?
  2. Erel

    Erel Administrator Staff Member Licensed User

    You can use Canvas to crop an image.
  3. Devv

    Devv Active Member Licensed User

    could you provide a link or example please ?
  4. Peter Simpson

    Peter Simpson Expert Licensed User

    Sub CropBitmap(Image As Bitmap, AcrossX As Int, DownY As Int, WidthX As Int, HeightY As Int) As Bitmap
    Dim JO As JavaObject
    Dim BmpCropped As Bitmap
            BmpCropped = JO.InitializeStatic(
    "").RunMethod("createBitmap"Array(Image, AcrossX, DownY, WidthX, HeightY))
    Return BmpCropped
    End Sub
    ilan, Yvon Steinthal, CHK and 3 others like this.
  5. Devv

    Devv Active Member Licensed User

    this code is working but it is cropping the image but rotated

    camEx.SavePictureToFile(Data, File.DirRootExternal, "1.jpg")
        b = CropBitmap(
    Dim out As OutputStream
        out = 
    File.OpenOutput(File.DirRootExternal, "1cr.jpg"False)
  6. CHK

    CHK New Member Licensed User

    I have now been searching for quite some time in this forum ... but this is by far the most elegant solution to crop an image. Many thanks to Peter Simpson.
  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