如何从CameraUI的在ActionScript 3.0图像旋转为iOS [英] How to rotate image from cameraUI for iOS in actionscript 3.0

查看:221
本文介绍了如何从CameraUI的在ActionScript 3.0图像旋转为iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建一个应用程序使用ActionScript 3.0在我的Flash Builder中。这是一个后续问题<一href="http://stackoverflow.com/questions/14740323/how-to-upload-a-picture-image-from-iphone-to-app-in-actionscript-3">this问题,它的工作原理,但是当我拍摄照片,拍摄的图像旋转到左边。我怎么能检查哪些方式,用户拿着手机?然后呢code做我使用到它的相应位置,将图像旋转?

I'm building an App with actionscript 3.0 in my Flash builder. This is a followup question to this question, It works but when I take the picture, the image comes out rotated to the left. how can I check which way the user is holding the phone? and then what code do I use to rotate the image to it's corresponding place?

在先进的感谢!

编辑: 我使用这个code旋转图像,但它似乎只旋转图像显示没有图像文件,任何想法?

I'm using this code to rotate the image, but it seems to only rotate the image being displayed not the image file, any ideas?

var mat:Matrix = new Matrix();
mat.translate(-W/2, -H/2);
mat.rotate(Math.PI/2);
mat.translate(+W/2, +H/2);
mat.concat(myObj.transform.matrix);
myObj.transform.matrix = mat;

〜MYY

推荐答案

您可以使用<一个href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html#deviceOrientation"相对=nofollow> Stage.deviceOrientation 或<一href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html#orientation"相对=nofollow> Stage.orientation *,以确定哪种方式轮手机。

You can use Stage.deviceOrientation or Stage.orientation* to determine which way round the phone is.

*不知道这一件作品在iOS

*not sure if this one works on iOS

时它的BitmapData结果本身要旋转(即创建一个新的BitmapData旋转的图像),或者只需旋转显示列表中的一个位图?

Is it the BitmapData result itself that you want to rotate (ie create a new BitmapData with rotated image) or just rotate a Bitmap on the display list?

编辑:

好吧,继承人一些code旋转BitmapData对象:

Ok, heres some code to rotate a BitmapData object:

function rotateBitmapData(angle:int, source:BitmapData):BitmapData
{
    var newWidth:int = source.rect.width;
    var newHeight:int = source.rect.height;
    if (angle==90 || angle==270)
    {
        newWidth = source.rect.height;
        newHeight = source.rect.width;
    }
    var newBmd:BitmapData = new BitmapData(newWidth, newHeight, source.transparent);
    var tx:Number = 0;
    var ty:Number = 0;
    if (angle==90 || angle==180)
    {
        tx = newWidth;
}
    if (angle==180 || angle==270)
    {
        ty = newHeight;
    }
    var matrix:Matrix = new Matrix();
    matrix.createBox(1, 1, Math.PI*angle/180, tx, ty);
    newBmd.draw(source, matrix);
    return newBmd;
}

角度应该是0,90,180或270这将返回指定角度旋转的新的BitmapData对象。

angle should be 0,90,180 or 270. It will return a new BitmapData object rotated by specified angle.

这篇关于如何从CameraUI的在ActionScript 3.0图像旋转为iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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