سلام دوستان من با استفاده از کد زیر از یه پنل اسکرین شات میگیرم ولی مشکلم اینه که بعد از اسکرین شات گرفتن از پنل اسکرین شات گرفته شده رو داخل imageview نشون میده . من فقط میخوام اسکرین شات رو ذخیره کنه و داخل image view نشون نده.
Sub PanelCapture(pnl As Panel, Img2 As ImageView)
Dim Obj1, Obj2 As Reflector
Dim bmp As Bitmap
Dim c As Canvas
Obj1.Target = Obj1.GetActivityBA
Obj1.Target = Obj1.GetField("vg")
bmp.InitializeMutable(pnl.left + pnl.Width, pnl.Top + pnl.Height)
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 canvas1 As Canvas
canvas1.Initialize(Img2)
Dim scrt As Rect
scrt.Initialize(pnl.left, pnl.top, pnl.left + pnl.Width, pnl.Top + pnl.Height)
Dim rectPanel1 As Rect
rectPanel1.Initialize(0, 0,Img2.Width, Img2.Height)
canvas1.DrawBitmap(bmp, scrt , rectPanel1)
Img2.Invalidate
End Sub
Sub Button1_Click
PanelCapture(Panel1,ImageView1)
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(Panel1.left + Panel1.Width, Panel1.Top + Panel1.Height)
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.DirRootExternal, dt & ".png", False)
bmp.WriteToStream(Out, 100, "PNG")
Out.Close
End Sub
سوال
amirs 2
سلام دوستان من با استفاده از کد زیر از یه پنل اسکرین شات میگیرم ولی مشکلم اینه که بعد از اسکرین شات گرفتن از پنل اسکرین شات گرفته شده رو داخل imageview نشون میده . من فقط میخوام اسکرین شات رو ذخیره کنه و داخل image view نشون نده.
Sub PanelCapture(pnl As Panel, Img2 As ImageView) Dim Obj1, Obj2 As Reflector Dim bmp As Bitmap Dim c As Canvas Obj1.Target = Obj1.GetActivityBA Obj1.Target = Obj1.GetField("vg") bmp.InitializeMutable(pnl.left + pnl.Width, pnl.Top + pnl.Height) 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 canvas1 As Canvas canvas1.Initialize(Img2) Dim scrt As Rect scrt.Initialize(pnl.left, pnl.top, pnl.left + pnl.Width, pnl.Top + pnl.Height) Dim rectPanel1 As Rect rectPanel1.Initialize(0, 0,Img2.Width, Img2.Height) canvas1.DrawBitmap(bmp, scrt , rectPanel1) Img2.Invalidate End Sub
Sub Button1_Click PanelCapture(Panel1,ImageView1) 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(Panel1.left + Panel1.Width, Panel1.Top + Panel1.Height) 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.DirRootExternal, dt & ".png", False) bmp.WriteToStream(Out, 100, "PNG") Out.Close End Sub
لینک ارسال
به اشتراک گذاری در سایت های دیگر
1 پاسخ به این سوال تاکنون داده شده است
ارسالهای توصیه شده
بایگانی شده
این موضوع بایگانی و قفل شده و دیگر امکان ارسال پاسخ نیست.