Hello wondrous all-knowing wizards of the xojo-iOS world!
I’m having some trouble getting iOSBitmap images to show as desired across different screen scales and was wondering if someone was able to show me why I am an idiot?
This is the desired effect (scale=1.0)
http://imgur.com/IetSgCP
Reading the documentation for iOSBitmaps it states:
“When creating an iOSBitmap you intend to put on screen, you want your bitmap to have the same scale factor as the screen and the number of pixels in each dimension multiplied by the scale factor.”
My understanding then is that to create an iOSBitmap to show on screen, it should be created like so:
dim scale as double = UI.MainScreenScale
dim p as iOSBitmap = new iOSBitmap(img.Width*scale, img.Height*scale, scale, true)
However, when I tried this, the resultant image appears like so (scale=2.0):
http://imgur.com/lgMWzi2
The code for it:
// make inactive btn img
dim img as iOSImage = Load.loadImage("button-panel-wide.png", "Images/")
dim scale as double = UI.MainScreenScale
dim p as iOSBitmap = new iOSBitmap(img.Width*scale, img.Height*scale, scale, true)
p.Graphics.DrawImage(img, 0, 0, p.Width, p.Height)
p.Graphics.FillColor = Color.RGBA(0, 0, 0, 100)
p.Graphics.FillRect(0, 0, p.Width, p.Height)
So, following the documentation, the result is an image 4x the size. Although the desired image (button-panel-wide) is drawn at the correct size, the overall image is 4x too big.
I tried a slightly different implementation, which appeared like so (scale=2.0):
http://imgur.com/1bPLzK9
The code for it:
// make inactive btn img
dim img as iOSImage = Load.loadImage("button-panel-wide.png", "Images/")
dim scale as double = UI.MainScreenScale
dim p as iOSBitmap = new iOSBitmap(img.Width, img.Height, scale, true)
p.Graphics.DrawImage(img, 0, 0, p.Width, p.Height)
p.Graphics.FillColor = Color.RGBA(0, 0, 0, 100)
p.Graphics.FillRect(0, 0, p.Width, p.Height)
This results in an overall image the correct size, but the desired image (button-panel-wide) is drawn at quarter the size.
Can anyone tell me what I need to do to create the image at the correct size? I’m stumped!