Android Question Cropping bitmap object

Said

Member
Licensed User
Longtime User
Hi,

Again similar question about capturing screen. Actually i want to capture entire panel to bitmap and then save it to file, but it doesnt work. I think tabhost causes conflict, i dont know. But all code examples captures entire screen from absoulute 0,0 top left position. And i am tired to work with rectangles.

Now i am trying another solution. Capturing entire screen and crop it. There are two crop points. From top about 40 dips, and from bottom, about 50 dips. I solved cropping bottom with code below.

B4X:
    Dim Obj1, Obj2 As Reflector
    Dim bmp As Bitmap
    Dim c As Canvas
    Dim now, i As Long
    Dim dt As String
    DateTime.DateFormat = "yyMMddHHmmss"
    now = DateTime.now
    dt = DateTime.Date(now)
    Obj1.Target = Obj1.GetActivityBA
    Obj1.Target = Obj1.GetField("vg")

    bmp.InitializeMutable(Activity.Width, Activity.Height-50dip)
    c.Initialize2(bmp)
    Dim args(1) As Object
    Dim types(1) As String
    Obj2.Target = c
    Obj2.Target = Obj2.GetField("canvas")
    args(0) = Obj2.Target
    types(0) = "android.graphics.Canvas"
    Obj1.RunMethod4("draw", args, types)
   
   
    Dim Out As OutputStream
    Out = File.OpenOutput(File.DirDefaultExternal, dt & ".png", False)
    bmp.WriteToStream(Out, 100, "PNG")
    Out.Close

Underlined bold line crops 50 dips from bottom. But i dont know how to crop top 40 dips. (What is 40 dips at top. Its tabhost header. I want to crop it. )

Any suggestion for newbie ?

Regards,

-Said
 
Top