Pixelcolor Path

ScaleFactor is a property of UIScreen which should be iOSScreen in Xojo.
Try
Declare function getScale lib UIKit selector "scale" (id as ptr) as CGFloat
And in your call to CGImage
dim newUIImage as ptr = imageWithCGImage(NSClassFromString(“UIImage”), cgimageref, getScale(App.CurrentScreen.handle), 0)

Other values for orientation are (upside)down = 1, left = 2, right = 3