iOS `Window.BitmapForCaching` equivalent?

Is there an iOS equivalent to the desktop Window.BitmapForCaching method?

I imagine you just can use a normal Picture.

API 1:

Dim p As iOSBitmap = New iOSBitmap(width, height, MainScreenScale)
Dim g As iOSGraphics = p.Graphics
g.Scale(p.Scale, p.Scale)

with

Public Function MainScreenScale() as Double
  //Jim McKay Retina detection
  
  Static value As Double
  
  if value < 1.0 then
    
    'Function MainScreenScale() As Double
    //declare function NSClassFromString lib "Foundation.Framework" (aClassName as CFStringRef) as Ptr
    declare function NSClassFromString lib "Foundation" (aClassName as CFStringRef) as Ptr
    soft declare function scale lib "UIKit" selector "scale" (classRef as Ptr) as CGFloat
    soft declare function mainScreen lib "UIKit" selector "mainScreen" (classRef as Ptr) as ptr
    
    
    value = scale(mainScreen(NSClassFromString("UIScreen")))
    
  End If
  
  Return value
  
End Function

API 2 ?

Awesome.

I’m trying to use API 2.0 if possible…

In API2 it seems to be something like this:

Dim scale As Double = MainScreenScale

Dim p As new Picture(100*scale, 100*scale)
p.HorizontalResolution = 72 * scale
p.VerticalResolution = 72 * scale

Dim g As Graphics = p.Graphics

g.ScaleX = scale
g.ScaleY = scale

I actually hate the way Picture works on iOS. If I want a 100x100 picture @3x I expect the width in points to be 100.
With Picture on iOS, it looks like it is necessary to multiply everything by the scale factor.

@Greg_O_Lone is there another way?

<https://xojo.com/issue/64062>

1 Like

Dang it that really how you have to do it on iOS??

Xojo does a reasonable job of abstracting that away on desktop. Not sure I’ll bother porting my game engine to iOS if I need to worry about scale with every picture calculation!

I think there is actually a bug with graphics.ScaleX graphics.ScaleY on iOS. Thus my feedback case.

In API1 it was super simple.