I’m trying to make another version of the BitmapForCaching method (Page Not Found — Xojo documentation) to extend it for the Window object (as seen below) since I can no longer directly access the windows graphics object in the latest release.
It seems to work but is it ok to replace g.ScaleX and g.ScaleY with w.ScaleFactor or could this cause unforeseen problems? Would it be better to directly call w.BitmapForCaching without the mask parameter to create a 1x1 pixel image and then use that’s g.ScaleX and g.ScaleY instead?
[code]Public Function BitmapForCaching(Extends w as Window, width as integer = -1, height as integer = -1, WithMask as boolean = False) as picture
#Pragma BackgroundTasks False
Dim pic As Picture
If WithMask then
pic = New Picture(widthw.ScaleFactor, heightw.ScaleFactor, 32)
Else
pic = New Picture(widthw.ScaleFactor, heightw.ScaleFactor)
End If
// Set the resolutions
pic.HorizontalResolution = 72 * w.ScaleFactor
pic.VerticalResolution = 72 * w.ScaleFactor
pic.Graphics.ClearRect(0, 0, pic.Width, pic.Height)
pic.graphics.ScaleX = w.ScaleFactor
pic.graphics.ScaleY = w.ScaleFactor
If WithMask then
pic.mask.graphics.scaleX = w.ScaleFactor
pic.mask.graphics.scaleY = w.ScaleFactor
End If
Return pic
End Function
[/code]