闪存CS5.5:照片旋转拍摄时使用CameraUI的iPhone上的照片 [英] Flash CS5.5: Photo is rotated when capture a photo using CameraUI on iPhone

查看:133
本文介绍了闪存CS5.5:照片旋转拍摄时使用CameraUI的iPhone上的照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮帮忙,我已经访问和捕获通过iPhone的摄像头的照片成功。但问题是,当我在加载它的loadFilePromise,照片旋转方向错误。

Please help, I already succeed in accessing and capturing a photo through camera of an iphone. But the problem is when I load it in by "loadFilePromise", a photo is rotated wrong direction.

import flash.media.CameraUI;
import flash.media.MediaType;
import flash.media.MediaPromise;
import flash.events.MediaEvent;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Loader;
import flash.display.Bitmap;
import flash.media.CameraRoll;
import flash.display.StageOrientation;
import flash.events.StageOrientationEvent;
import flash.media.Camera;
import flash.media.Video;

var currentOrientation:String = "";

var cam:CameraUI = new CameraUI();
cam.addEventListener(MediaEvent.COMPLETE, captured);
cam.addEventListener(Event.CANCEL, cancelled);

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, photoLoaded);
addChild(loader);

captureBtn.addEventListener(MouseEvent.MOUSE_UP, pressed);

function pressed(e:MouseEvent){
    if(CameraUI.isSupported){
        cam.launch(MediaType.IMAGE);
    }
}

function captured(e:MediaEvent){
    var mediaPromise:MediaPromise = e.data;
    if(mediaPromise != null)
    {
        output.text = "Photo captured.";
        loader.loadFilePromise(mediaPromise);
    }
}

function cancelled(e:Event):void {
    output.text = "Cancelled.";
}

stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING,orientationChanging);
stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, orientationChanged);

function orientationChanging(e:StageOrientationEvent){
    currentOrientation = e.afterOrientation;
    trace(currentOrientation);
    switch(currentOrientation)
    {
        case StageOrientation.DEFAULT :
            currentOrientation = "DEFAULT";
            //set rotation value here
            stage.rotation = 0;
            break;

        case StageOrientation.ROTATED_RIGHT :
            currentOrientation = "ROTATED_RIGHT";
            //set rotation value here
            stage.rotation = -90;
            break;

        case StageOrientation.ROTATED_LEFT :
            currentOrientation = "ROTATED_LEFT";
            //set rotation value here
            stage.rotation = 90;
            break;

        case StageOrientation.UPSIDE_DOWN :
            currentOrientation = "UPSIDE_DOWN";
            //set rotation value here
            stage.rotation = 180;
            break;
    }
}

function orientationChanged(e:StageOrientationEvent){

}

function photoLoaded(e:Event){
    var img:Bitmap = e.currentTarget.content as Bitmap;
    img.smoothing = true;
    img.width = 350
    img.scaleY = img.scaleX;

    /* TRY THIS TO FIX BUT IT DIDN'T WORK:
        switch(currentOrientation){

        case "rotatedLeft":
            img.rotation = 90;
        break;

        case "rotatedRight":
            img.rotation = 90;
        break;

        case "upsideDown":

        break;

    }*/

    /* THESE LINE ARE JUST USED TO SAVE PHOTO IN CAMERA ROLL:
        if(CameraRoll.supportsAddBitmapData)
    {
        cameraRoll.addBitmapData(img.bitmapData);
    }*/
}

function camRollSaved(e:Event){
    output.text = "Your photo is saved to a camera roll."
}

我已经选中自动定位的发布设置,试图纠正StageOrientation,但它仍然没有奏效。

I already unchecked "Auto orientation" in publish settings, tried to correct StageOrientation but it still didn't work.

stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING,orientationChanging);
stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, orientationChanged);

当我旋转一个iphone来lanscape(与在右上角的摄像头的位置),这是唯一正确的,然后进行拍摄。

It's only correct when I rotate an iphone to lanscape (with the camera's position at TOP-RIGHT), then take a picture.

有没有人有同样的问题,或不知道如何解决呢?

Does anyone has the same problem or know how to solve it?

太感谢了,

推荐答案

这解决了这个问题,我在Android: http://blog.flexnroses.com/?p=95

This solved it for me on Android: http://blog.flexnroses.com/?p=95

我认为这是与库iOS的一个问题,所以它可能不是解决你的问题,但也许你可以得到你从这个所需要的灵感。祝你好运!

I think there is a problem with the libraries for iOS, so it might not solve your problem, but maybe you can get the inspiration you need from this. Good luck!

这篇关于闪存CS5.5:照片旋转拍摄时使用CameraUI的iPhone上的照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆