移动应用程序中图像的转换
我尝试为 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否使用“gpu”渲染模式来测试?
并尝试使用位图代替
Are you using "gpu" renderMode to test?
And try use bitmap instead