iOSImage.FromFile looses scale

My app uses a lot of images that come from a network location.

I load images using a HTTPSocket and then save them to the Caches folder.
Just before caching the file, I rescale it to the current device screen scale.

Example in iOS Simulator
Retrieved image:
Width: 50
Height: 50
Scale: 1

Scaled imaged:
Width: 25
Height: 25
Scale: 2

After saving the file in the iOS simulator, I can access it through the Finder and preview the saved file.
It is displayed as Retina with the following properties:
Width: 50
Height: 50
144dpi

But when I open back the image in the iOS simulator, the scale is lost and I’m back to:
Width: 50
Height: 50
Scale: 1

Is this behaviour as expected ?

I had to come up with the following about a year ago because images were being rotated when I saved and loaded them from disk with the Xojo methods. Maybe it will help you (just replace the portions in all caps with your values):
Load an image:

dim t as Text = IMAGEFILENAME declare function imageWithData lib UIKitLib selector "imageWithData:" (clsRef as ptr, data as ptr) as ptr dim d as new Foundation.NSData(xojo.io.SpecialFolder.Documents.Child(t)) dim img as Ptr = imageWithData(NSClassFromString("UIImage"),d) self.image = iOSImage.FromHandle(img)

Save an image:

[code]dim image as iOSImage = IMAGETOSAVE

Declare function UIImageJPEGRepresentation lib UIKitLib (obj_id as ptr) as ptr
dim d as new Foundation.NSData(UIImageJPEGRepresentation(image.Handle))

dim f as xojo.IO.FolderItem = xojo.io.SpecialFolder.Documents.Child(IMAGEFILENAME)
call d.WriteToFile(f.Path, True)[/code]

Thanks Jason, unfortunately it doesn’t help.

The images are still opened with scale = 1, although they were saved with scale = 2

From now on I’ll just assume that all images saved to cache are in scale = 1 and I need to rescale them before displaying them.