Dim bg As Object
bg = GetWallpaperBackground
'Activity.Background = bg
If bg Is BitmapDrawable Then
ToastMessageShow("is drawable!",True)
Dim bd As BitmapDrawable
bd = bg
Dim Out As OutputStream
Out = File.OpenOutput(File.DirRootExternal, "saved_wallpaper.png", False)
'bd.WriteToStream(Out, 100, "PNG")
Dim btm As Bitmap
btm = bd.Bitmap
btm.WriteToStream(Out, 100, "PNG")
Out.Close
Else
ToastMessageShow("is NOT drawable!",True)
Dim bt As Bitmap
bt = bg
'Create a mutable Bitmap with Bitmap.InitializeMutable.
Dim w As Int 'width
Dim l As Int 'length
w = bt.Width
l = bt.Height
Dim btm As Bitmap
btm.InitializeMutable(w,l) ' todo get layout from device layout ?? or from bg ?
'Create a Canvas For this Bitmap.
Dim can As Canvas
'Draw the drawable with Canvas.DrawDrawable
Dim DestRect As Rect
DestRect.Initialize(0,0, w, l)
can.DrawDrawable(bg,DestRect)
'Save the Bitmap To a File (Bitmap.WriteToStream)
Dim Out As OutputStream
Out = File.OpenOutput(File.DirRootExternal, "saved_wallpaper1.png", False)
btm.WriteToStream(Out, 100, "PNG")
End If