Note that there are some explanatory texts on larger screens.

plurals
  1. POImages not saved correctly in iOS
    primarykey
    data
    text
    <p>I'm having an issue whenever I am saving a .png image to my iOS Applications.</p> <pre><code>-(UIImage *) getImageFromURL:(NSString *)fileURL { UIImage * result; NSData * data = [NSData dataWithContentsOfURL:[NSURL URLWithString:fileURL]]; result = [UIImage imageWithData:data]; return result; } -(void) saveImage:(UIImage *)image withFileName:(NSString *)imageName ofType:(NSString *)extension inDirectory:(NSString *)directoryPath { if ([[extension lowercaseString] isEqualToString:@"png"]) { [UIImagePNGRepresentation(image) writeToFile:[directoryPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", imageName, @"png"]] options:NSAtomicWrite error:nil]; } else if ([[extension lowercaseString] isEqualToString:@"jpg"] || [[extension lowercaseString] isEqualToString:@"jpeg"]) { [UIImageJPEGRepresentation(image, 1.0) writeToFile:[directoryPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", imageName, @"jpg"]] options:NSAtomicWrite error:nil]; } else { NSLog(@"Image Save Failed\nExtension: (%@) is not recognized, use (PNG/JPG)", extension); } } </code></pre> <p>The code above is what I'm using to download the images with, passing it a url to an image and then "png" as the file type.</p> <p>For some reason, the image saves onto the devices, but it saves in an incorrect format. I've tested this by pulling up the iPhone Simulator program application folder and looking at the images directly. They are indeed saved, but even Mac OS X can't open them up as "Images" with Preview.</p> <p>Am I doing something wrong? These images are actual png images that I'm just downloading to the device. This was previously working a week ago, now it isn't.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload