3

iPhoneで画像を正しく配置する際に問題があります。私はAssetLibraryクラスを使って画像にアクセスしています。ALAssetOrientationとUIImageOrientationを使用して正しい向きを特定する際の問題

私は、表示する画像を適切に配置することをお勧めします。残念なことに、ポートレートモードで撮影された画像では意味をなさない方向にあります。フレームワークによって呼び出されますブロックで

、私はそれが配向している間にiPhoneのカメラで撮影された画像については、以下の呼び出しを「アップ」作っています:

 ALAssetRepresentation *representation = [myasset defaultRepresentation]; 
     ALAssetOrientation  orient   = [representation orientation]; 
     ALAssetOrientation  alorient = [[myasset valueForProperty:@"ALAssetOrientation"] intValue]; 
     UIImage     *timg   = [[UIImage alloc] initWithCGImage:[representation fullScreenImage]]; 
     UIImageOrientation  imgorient  = [timg imageOrientation]; 

THe variable orient = ALAssetOrientationRight. 
The variable alorient = ALAssetOrientationUp. 
The variable imgorient = UIImageOrientationUp 

私が使っていました画像を回転させて「上に」表示されるようにします。残念ながら、風景モードで撮影された画像があると、向きが正しくないため同じコードが機能しません。

scale:orientation:orientをorientパラメータで使用して、timgをインスタンス化しようとしましたが、画像を初期化してイメージを正しく回転しません。あなたの助けを大幅に高く評価されます

ALAssetOrientation  orient = [representation orientation]; 
ALAssetOrientation  alorient = [[myasset valueForProperty:@"ALAssetOrientation"] intValue]; 

:。

これは、これらの呼び出しは異なる結果を返す方法を来る、非決定論的と思われます問題は、あなたが間違ったプロパティ名を使用していることである

おかげで、 ウィル

+0

真剣に、誰もこれにコメントがありませんでしたか?!! – willmapp

答えて

0

。あなたのコードで

[[myasset valueForProperty:@"ALAssetOrientation"] intValue]; 

は次のようになります。

[[myasset valueForProperty:@"ALAssetPropertyOrientation"] intValue]; 

documentation-[ALAsset valueForProperty:]

If property is not a valid key, returns ALErrorInvalidProperty. 
0によると、

ALErrorInvalidPropertyをintにキャストしようとすると、0になります。偶然によると、ALAssetOrientationUpの値は0なので、alorientの変数は常にALAssetOrientationUpと評価されます。

関連する問題