画像のサイズを変更して、画像の中心の拡大縮小されたチャンクを取得できるコードをいくつか持っています。これを使用して、画像UIImage
の小さな正方形の表現を取得して返します。写真アプリ。UIImageView
( を使用してクロップ モードを調整しても同じ結果が得られることはわかっていますが、これらの画像は で表示されることがありますUIWebViews
)。
このコードでいくつかのクラッシュに気付き始めたので、少し困惑しています。私には 2 つの異なる説がありますが、どちらが基地内にあるのか疑問に思っています。
理論 1) ターゲット サイズのオフスクリーン イメージ コンテキストに描画することで、クロッピングを実現します。画像の中央部分が必要なので、CGRect
渡された引数をdrawInRect
画像コンテキストの境界よりも大きいものに設定します。これがコーシャであることを願っていましたが、触れてはいけない他の記憶を引きずり込もうとしているのですか?
理論 2) 私はこれらすべてをバックグラウンド スレッドで実行しています。メインスレッドに制限されている UIKit の部分があることは知っています。私は、オフスクリーンビューへの描画がこれらの1つではないことを想定/望んでいました. 私が間違っている?
(ああ、方法が恋しいNSImage's drawInRect:fromRect:operation:fraction:
。)