views:

30

answers:

1

I have the following 2 issues with iPhone 4 images. Any help is appreciated.

  1. When using iPhone 4 if I access an image from photo library in my app and save it in a database, then retrieve it again, I see it has lost resolution. The same works fine on 3G - no loss of resolution. Any idea why this could be happening?

  2. I am using retina scan images on iPhone 4 for buttons. They are set directly from the IB. Sometimes I see they are skewed to half the height and same width. Again, this is not seen on 3G and everything works fine.

Any help is much appreciated.

Here's the code which I use to access from library. I dont think saving to database is causing it. I am using an "ImageToDataTransformer".

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    UIImage *img;
    img =   [self scaleAndRotateImage:[info objectForKey:UIImagePickerControllerOriginalImage]];

    imageView.image = [img  imageByScalingProportionallyToSize:targetSize];
}

In scaleAndRotateImage I use "static int kMaxResolution = 640;" Will this work for iPhone 4? May be this could be the issue.

Code for scaleAndRotateImage is found here

A: 

These are really two separate issues.

For saving the images, I'm guessing that somewhere you're calling UIGraphicsBeginImageContext. Instead you should use UIGraphicsBeginImageContextWithOptions. This link has more details. (If you want to support both 3.x and 4.x devices, you'll have to check that the function exists before you call it. See here for details on how to do this. If it doesn't exist, call the original method instead.)

The button issue is harder to diagnose. Make sure your "@2x" images are named correctly (including case sensitivity), and they really are exactly double resolution. Beyond that, it's hard to say. I would review this and double check that you're doing everything correctly.

Robot K