移动应用程序中图像的转换

发布于 2024-12-27 22:43:17 字数 1656 浏览 2 评论 0原文

我尝试为 Android 创建一个简单的拼贴设计器。每个图像都可以移动、旋转、缩放。使用此代码:

var os:Sprite = new Sprite();
os.cacheAsBitmap = true;
                os.cacheAsBitmapMatrix = new Matrix();
                Multitouch.inputMode = MultitouchInputMode.GESTURE;
                if (Multitouch.supportsGestureEvents){
                    os.addEventListener(TransformGestureEvent.GESTURE_ROTATE , onRotate );
                    os.addEventListener(TransformGestureEvent.GESTURE_ZOOM , onZoom);
                    os.addEventListener(TransformGestureEvent.GESTURE_PAN , onPan);
                }
                os.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
                os.addEventListener(MouseEvent.MOUSE_UP, onUp);

protected function onRotate(event:TransformGestureEvent):void
            {
                event.target.rotation += event.rotation;
            }

            protected function onZoom(event:TransformGestureEvent):void
            {
                event.target.scaleX *= event.scaleX;
                event.target.scaleY *= event.scaleY;
            }

            protected function onPan(event:TransformGestureEvent):void
            {
                event.target.x = event.offsetX;
                event.target.y = event.offsetY;
            }
            protected function onDown(e:MouseEvent):void
            {
                os.startDrag();
                e.stopPropagation();
            }

            protected function onUp(e:MouseEvent):void
            {
                os.stopDrag();
            }

但是,缩放图像不平滑,图像突然改变大小,运动拉动。虽然我有一个相当强大的测试设备。我无法使用使用标记的标准方法,因为图像非常小,并且将手指敲入标记会很困难。

请提示代码示例如何实现这一点。

I tried to create a simple collage designer for Android. Each image can be moved, rotated, scaled. Use this code:

var os:Sprite = new Sprite();
os.cacheAsBitmap = true;
                os.cacheAsBitmapMatrix = new Matrix();
                Multitouch.inputMode = MultitouchInputMode.GESTURE;
                if (Multitouch.supportsGestureEvents){
                    os.addEventListener(TransformGestureEvent.GESTURE_ROTATE , onRotate );
                    os.addEventListener(TransformGestureEvent.GESTURE_ZOOM , onZoom);
                    os.addEventListener(TransformGestureEvent.GESTURE_PAN , onPan);
                }
                os.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
                os.addEventListener(MouseEvent.MOUSE_UP, onUp);

protected function onRotate(event:TransformGestureEvent):void
            {
                event.target.rotation += event.rotation;
            }

            protected function onZoom(event:TransformGestureEvent):void
            {
                event.target.scaleX *= event.scaleX;
                event.target.scaleY *= event.scaleY;
            }

            protected function onPan(event:TransformGestureEvent):void
            {
                event.target.x = event.offsetX;
                event.target.y = event.offsetY;
            }
            protected function onDown(e:MouseEvent):void
            {
                os.startDrag();
                e.stopPropagation();
            }

            protected function onUp(e:MouseEvent):void
            {
                os.stopDrag();
            }

However, scaling images is not smooth, the image suddenly changes size, motion pull. Although I have quite a powerful device for testing. I can not use a standard way using markers, because the images are quite small, and tap your finger into the marker will be difficult.

Prompt code examples how this can be implemented, please.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一片旧的回忆 2025-01-03 22:43:17

您是否使用“gpu”渲染模式来测试?
并尝试使用位图代替

Are you using "gpu" renderMode to test?
And try use bitmap instead

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文