マスクされた画像がたくさんあるアプリがあります。パフォーマンスのために、これらのマスクされたイメージをディスク上に生成し、アプリに組み込む必要がありました (既に完了しているため、オンザフライでマスクされずにオンデマンドでアップロードされます)。
私はこの種のコーディングを使用しています
NSString *pngPath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/Test_%d.png",i]];
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Documents/Test_%d.jpg",i]];
// Write a UIImage to JPEG with minimum compression (best quality)
// The value 'image' must be a UIImage object
// The value '1.0' represents image compression quality as value from 0.0 to 1.0
[UIImageJPEGRepresentation([self maskImageWithStroke:image withMask:maskImage], 1.0) writeToFile:jpgPath atomically:YES];
// Write image to PNG
[UIImagePNGRepresentation([self maskImageWithStroke:image withMask:maskImage]) writeToFile:pngPath atomically:YES];
私の中間画像では完全に機能しますが、最終画像では機能しません。
私が使用する複数のマスクとブランのプロセスは次のとおりです。
画像を取得し、それをマスクして maskedImage を取得します
リスト アイテムのマスクを取得し、サイズを少し大きくします。
maskedImage と bigmask をブレンドして、maskedStrokedImage を biggrMask でストロークします (これは、不規則なマスク イメージに不規則なストロークを追加する唯一の方法です)。
最終的な結果を得るために、 maskedStrokedImage を bigMask でマスクします。
問題は次のとおりです。ステップ 1 で取得した画像を保存しても問題ありません。必要なものが正確に含まれた JPG と PNG があります。
私の目標は、ステップ 4 の結果をディスクに保存することですが、結果はストロークの一部を示す imahe であり、残りは白です ...
ステップ 4 をディスクに保存できない理由はありますか?