Sub CreateScaledBitmap(bmp As Bitmap, Width As Int, Height As Int)
Width = Width / (100dip / 100) '100dip / 100 = device scale
Height = Height / (100dip / 100)
Dim D As Rect
Dim xBuildPicture As Bitmap
xBuildPicture.InitializeMutable(Width, Height)
Dim xBuildCanvas As Canvas
xBuildCanvas.Initialize2(xBuildPicture)
D.Initialize(0,0,Width, Height)
xBuildCanvas.drawBitmap(bmp, Null, D)
Dim out As OutputStream
out = File.OpenOutput(File.DirRootExternal, "bitmap.png", False)
xBuildPicture.WriteToStream(out,100, "PNG")
out.Close
End Sub