iPhoneアプリでは、最大サイズ300Koのメールでjpgを送信する必要があります(mail.appの最大サイズはありませんが、別の問題です)。そのために、300Ko以下の画像が得られるまで品質を下げようとしています。
300Ko未満のjpgを取得する品質(compressionLevel)の適切な値を取得するために、次のループを作成しました。動作していますが、ループを実行するたびに、「[tmpImagerelease];」にもかかわらず、元のサイズのjpg(700Ko)のサイズのメモリが増加します。
float compressionLevel = 1.0f;
int size = 300001;
while (size > 300000) {
UIImage *tmpImage =[[UIImage alloc] initWithContentsOfFile:[self fullDocumentsPathForTheFile:@"imageToAnalyse.jpg"]];
size = [UIImageJPEGRepresentation(tmpImage, compressionLevel) length];
[tmpImage release];
//In the following line, the 0.001f decrement is choose just in order test the increase of the memory
//compressionLevel = compressionLevel - 0.001f;
NSLog(@"Compression: %f",compressionLevel);
}
どうすればそれを取り除くことができますか、またはなぜそれが起こるのかについてのアイデアはありますか?ありがとう