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
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]