2011-10-21 1 views
-3

iPhoneアプリで使用しているpng画像について質問があります。私はさまざまなビューのために大きな画像をたくさん持っていますが、それらは圧縮されていますが、アプリケーションがまったく遅くなるかどうかは疑問でした。基本的には、イメージを調整するだけで、サイズを小さくして高速にする方法を知る必要がありますか?それとも、それを混乱させる価値があるのか​​?iPhoneアプリ開発者の大きいPNG画像

私はこのトピックについて研究しましたが、画像を圧縮する以外に実行可能な解決策は見つかりませんでした。

何かお手伝いがありますか?

+0

提案は:今までにない大きさの点では、解像度の点で大きな画像を使用しないでください。画像がiPhoneの画面よりも解像度が高い場合は、インターフェースビルダーによって圧縮されていても、アプリケーションに大きな混乱が生じます。 –

+0

@AnilKumarReddy提案をありがとう! – PetersCodeProblems

答えて

1

アプリを使用すると、読み込みに時間がかかることがありますか?もしそうでなければ、画像を乱しても構いませんが、利益は最小限に抑えられます。

アプリの読み込みに問題がある場合は、それがPNGであるとはみなさないでください。提供されたツールを使用してアプリのプロファイルを作成し、遅い部分が何であるかを見つけてそこから開始します。遅いコードの原因を知っているとは決して考えないでください。

+0

これは私が知っている。私は大きな画像のために可能な解決策が何であるか疑問に思っていました。 – PetersCodeProblems

+0

私の質問に答えてくれてありがとう。 – PetersCodeProblems

2

希望、これは役立ちます!

http://www.iphonedevsdk.com/forum/iphone-sdk-development/7307-resizing-photo-new-uiimage.html

 -(UIImage *)resizeImage:(UIImage *)image { 

CGImageRef imageRef = [image CGImage]; 
CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(imageRef); 
CGColorSpaceRef colorSpaceInfo = CGColorSpaceCreateDeviceRGB(); 

if (alphaInfo == kCGImageAlphaNone) 
    alphaInfo = kCGImageAlphaNoneSkipLast; 

int width, height; 

width = 640; 
height = 480; 

CGContextRef bitmap; 

if (image.imageOrientation == UIImageOrientationUp | image.imageOrientation == UIImageOrientationDown) { 
    bitmap = CGBitmapContextCreate(NULL, width, height, CGImageGetBitsPerComponent(imageRef), CGImageGetBytesPerRow(imageRef), colorSpaceInfo, alphaInfo); 

} else { 
    bitmap = CGBitmapContextCreate(NULL, height, width, CGImageGetBitsPerComponent(imageRef), CGImageGetBytesPerRow(imageRef), colorSpaceInfo, alphaInfo); 

} 

if (image.imageOrientation == UIImageOrientationLeft) { 
    NSLog(@"image orientation left"); 
    CGContextRotateCTM (bitmap, radians(90)); 
    CGContextTranslateCTM (bitmap, 0, -height); 

} else if (image.imageOrientation == UIImageOrientationRight) { 
    NSLog(@"image orientation right"); 
    CGContextRotateCTM (bitmap, radians(-90)); 
    CGContextTranslateCTM (bitmap, -width, 0); 

} else if (image.imageOrientation == UIImageOrientationUp) { 
    NSLog(@"image orientation up"); 

} else if (image.imageOrientation == UIImageOrientationDown) { 
    NSLog(@"image orientation down"); 
    CGContextTranslateCTM (bitmap, width,height); 
    CGContextRotateCTM (bitmap, radians(-180.)); 

} 

CGContextDrawImage(bitmap, CGRectMake(0, 0, width, height), imageRef); 
CGImageRef ref = CGBitmapContextCreateImage(bitmap); 
UIImage *result = [UIImage imageWithCGImage:ref]; 

CGContextRelease(bitmap); 
CGImageRelease(ref); 

return result; 

}

関連する問題