简体   繁体   English

Flash CS5.5:在iPhone上使用CameraUI捕获照片时,照片会旋转

[英]Flash CS5.5: Photo is rotated when capture a photo using CameraUI on iPhone

Please help, I already succeed in accessing and capturing a photo through camera of an iphone. 请帮助,我已经成功通过iPhone的相机访问和捕获照片。 But the problem is when I load it in by "loadFilePromise", a photo is rotated wrong direction. 但是问题是当我通过“ loadFilePromise”将其加载时,照片旋转方向错误。

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."
}

I already unchecked "Auto orientation" in publish settings, tried to correct StageOrientation but it still didn't work. 我已经在发布设置中取消选中“自动方向”,试图更正StageOrientation,但仍然无法正常工作。

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

It's only correct when I rotate an iphone to lanscape (with the camera's position at TOP-RIGHT), then take a picture. 仅当我旋转iphone使其横向(相机的位置在TOP-RIGHT位置)然后拍照时,这才是正确的。

Does anyone has the same problem or know how to solve it? 是否有人遇到相同的问题或知道如何解决?

Thanks so much, 非常感谢,

This solved it for me on Android: http://blog.flexnroses.com/?p=95 这为我在Android上解决了该问题: http//blog.flexnroses.com/?p = 95

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. 我认为iOS的库存在问题,因此它可能无法解决您的问题,但是也许您可以从中获得所需的灵感。 Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 屏幕锁定和声音停止 iPhone 开发 (FLASH CS5.5) - Screen Lock & sound stop iPhone dev (FLASH CS5.5) 如何删除iphone图标的光泽效果? (在Flash CS5.5中) - How to remove iphone icon gloss effect? (in FLASH CS5.5) 使用AVFoundation在Iphone照片捕获中,图像捕获比闪光灯慢 - Image capture is slower than flash in Iphone photo capture using AVFoundation Flash CS5.5 Iphone App OTA 分发和/或同步而无需删除应用程序 - Flash CS5.5 Iphone App OTA distribution and or sync without removing apps 使用flash cs5.5创建的应用程序需要哪些版本的ios? - What version of ios is required for apps created with flash cs5.5? 拍照时取下iPhone 4双闪? - Remove iPhone 4 double flash when taking photo? 正在开发iPhone应用程序Adobe Professional CS5.5 Windows版本? - Developing iphone app Adobe Professional CS5.5 windows version? 是否使用phonegap将捕获的图像保存在iPhone的照片库中 - Is capture image Saved in Photo Library of iPhone using phonegap 使用javascript从iPhone / Android相机中捕捉照片 - Using javascript to capture photo from iPhone / Android Camera Dreamweaver CS5.5真的可以将我的网页转换为iPhone应用程序吗? - Can Dreamweaver CS5.5 really turn my web page into an iPhone app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM