I’ve been trying to use iOSBitmap in an app and its quirks have surprised me. According to the docs, you must supply the screen scale and multiply both the height and width by the scale factor. Unfortunately, multiplying the height and width by the scale makes no difference when the bitmap is converted to an image and drawn into a graphics object. Some very simple code which should produce the same result but does not:
In a canvas paint event:
g.FillColor = Color.blue
g.FillRect 0,0,g.Width,g.Height
g.FillColor = Color.black
g.DrawTextLine "This is a canvas", 10, g.Height/2
In another canvas paint event:
[code] dim bitmap as new iOSBitmap(g.WidthScreenScale, g.HeightScreenScale, ScreenScale)
dim g2 as iOSGraphics = bitmap.Graphics
g2.FillColor = Color.blue
g2.FillRect 0,0,g.Width,g.Height
g2.FillColor = Color.black
g2.DrawTextLine “This is a canvas”, 10, g.Height/2
g.DrawImage bitmap.Image, 0, 0[/code]
A function you will need:
[code]Function ScreenScale() As Double
'[[UIScreen mainScreen] scale]
declare function mainScreen lib UIKitLib selector “mainScreen” (clsRef as ptr) as ptr
#if Target32Bit
declare function scale Lib UIKitLib selector “scale” (obj_id as ptr) as Single
#elseif Target64Bit
declare function scale Lib UIKitLib selector “scale” (obj_id as ptr) as Double
#Endif
Return scale(mainScreen(NSClassFromString(“UIScreen”)))
End Function[/code]
Am I somehow missing something in iOSBitmap, or does it not work as intended with scales greater than 1? Using a scale of one in the above code makes the drawing the correct dimensions, but everything is blurry because the screen has a scale of 2.
I would appreciate any insight or work arounds to make this work correctly for scales greater than 1.
Thanks,
Jason