- 浏览: 1453996 次
- 性别:
- 来自: 苏州
文章分类
- 全部博客 (564)
- 算法 (7)
- 流金岁月 (1)
- Javascript (30)
- actionscript (108)
- as3.0 game (14)
- flex (84)
- fms2 (27)
- 正则表达式 (7)
- 开源组件代码(as3.0) (1)
- Pv3d (13)
- Cairngorm (4)
- vbs (54)
- VB程序设计 (26)
- 计算机应用与维护 (4)
- 职场实用穿衣技巧 (3)
- 历史风云 (15)
- 淡泊明志,宁静致远 (12)
- 情感 (26)
- 杂谈 (41)
- 越南风 (14)
- DirectX (9)
- Dev-cpp (11)
- 回望百年 (2)
- 建站经验 (2)
- Python (24)
- 网络赚钱 (4)
- php (2)
- html (1)
- ob0短址网 (1)
- ob0.cn (1)
- wordpress (1)
- pandas logistic (1)
- haxe (1)
- opencv (1)
- 微信小程序 (3)
- vue (3)
- Flutter (1)
最新评论
-
GGGGeek:
第一个函数滚动监听不起作用,onPageScroll可以
微信小程序--搜索框滚动到顶部时悬浮 -
naomibyron:
解决办法:工具 -> 编译选项 -> 编译器 ...
dev-c++中编译含WINSOCK的代码出现错误的解决方法 -
haichuan11:
这个…… 代码不全真的是让人很憋屈的感觉啊
actionScript 3.0 图片裁剪及旋转 -
chenyw101:
老兄能留个QQ号吗?具体的我有些东西想请教下你
用VB制作网站登陆器 -
yantao1943:
貌似有点问题,只派发一次事件啊
使用ActionScript 2.0或ActionScript 3.0处理音频文件的提示点(cue
和师傅写C#写的思维混乱,方法变量几乎第一反应就是大写,习惯都被改写了,.NET在代码管理上的确比Flex强悍的多。
OK,进入主题,毕设还没结束就先回公司报道了,哈哈,接下来事情不少。这个是一个项目开始要用到的,一大堆的Rectangle运算处理,头痛了一整天,其中的SelectRectanle用于选取框的生成,可拖拽,缩放,返回一个给定可视元素的被选区域(Rectangle), CutImage用于剪裁图片。
查看源代码:http://www.moorwind.com/as3app/imageprocess/srcview/index.html
代码中注意,因为要对图片进行操作,所以使用了URLStream()加载待处理图像。
view plaincopy to clipboardprint?
//选取框
package com.moorwind.imageprocesser.utils
{
import com.moorwind.imageprocesser.ui.ScaleButton;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import flash.net.URLLoader;
public class SelectRectangle extends URLLoader
{
private var target:Sprite
private var onlayer:Sprite;
private var startX:Number;
private var startY:Number;
private var dragX:Number;
private var dragY:Number;
private var drawRect:Rectangle;
private var scaleButton:ScaleButton;
public static const SELECTED:String = "selected";
public var lineColor:int = 0x0099FF;
public var fillColor:int = 0x0099FF;
public var fillAlpha:Number = 0.1;
public var isSelectRectangleFinished:Boolean = false;
public var isScaleable:Boolean = false;
public function SelectRectangle(target:Sprite, onlayer:Sprite)
{
this.target = target;
this.onlayer = onlayer;
this.onlayer.buttonMode = true;
}
//get selected rectangle
public function get selectRectangle():Rectangle
{
return this.isSelectRectangleFinished ? this.drawRect : null;
}
// initial rectangle
public function InitSelectRectangle():void
{
if(this.isSelectRectangleFinished)
return;
this.target.addEventListener(MouseEvent.MOUSE_DOWN, this.StartDrawRect);
}
private function StartDrawRect(e:MouseEvent):void
{
this.startX = this.target.mouseX;
this.startY = this.target.mouseY;
this.target.addEventListener(MouseEvent.MOUSE_MOVE, this.DrawingRect);
this.target.addEventListener(MouseEvent.MOUSE_UP, this.EndDrawRect);
}
private function DrawingRect(e:MouseEvent):void
{
this.drawRect = new Rectangle(this.startX,this.startY,this.target.mouseX - this.startX,this.target.mouseY - this.startY);
this.onlayer.graphics.clear();
this.onlayer.graphics.lineStyle(1,this.lineColor,1);
this.onlayer.graphics.beginFill(this.fillColor,this.fillAlpha);
this.onlayer.graphics.drawRect(this.drawRect.x,this.drawRect.y,this.drawRect.width,this.drawRect.height);
this.onlayer.graphics.endFill();
e.updateAfterEvent();
}
private function EndDrawRect(e:MouseEvent):void
{
this.isSelectRectangleFinished = true;
this.target.removeEventListener(MouseEvent.MOUSE_DOWN, this.StartDrawRect);
this.target.removeEventListener(MouseEvent.MOUSE_MOVE, this.DrawingRect);
this.target.removeEventListener(MouseEvent.MOUSE_UP, this.EndDrawRect);
this.scaleButton = new ScaleButton();
this.onlayer.addChild(this.scaleButton);
this.scaleButton.x = this.drawRect.x+this.drawRect.width;
this.scaleButton.y = this.drawRect.y+this.drawRect.height;
this.dispatchEvent(new Event(SelectRectangle.SELECTED));
this.StartScaleButton();
this.InitDragEvent();
}
// scale rectangle
public function StartScaleButton():void
{
this.scaleButton.addEventListener(MouseEvent.MOUSE_DOWN, this.StartScaleRect);
}
private function StartScaleRect(e:MouseEvent):void
{
this.isScaleable = true;
this.target.addEventListener(MouseEvent.MOUSE_MOVE, this.ScalingRect);
this.target.addEventListener(MouseEvent.MOUSE_UP, this.EndScaleRect);
}
private function ScalingRect(e:MouseEvent):void
{
this.drawRect = new Rectangle(this.drawRect.x,this.drawRect.y,this.target.mouseX - this.drawRect.x,this.target.mouseY - this.drawRect.y);
this.onlayer.graphics.clear();
this.onlayer.graphics.lineStyle(1,this.lineColor,1);
this.onlayer.graphics.beginFill(this.fillColor,this.fillAlpha);
this.onlayer.graphics.drawRect(this.drawRect.x,this.drawRect.y,this.drawRect.width,this.drawRect.height);
this.onlayer.graphics.endFill();
this.scaleButton.x = this.drawRect.x+this.drawRect.width;
this.scaleButton.y = this.drawRect.y+this.drawRect.height;
e.updateAfterEvent();
}
private function EndScaleRect(e:MouseEvent):void
{
this.isScaleable = false;
this.target.removeEventListener(MouseEvent.MOUSE_MOVE, this.ScalingRect);
this.target.removeEventListener(MouseEvent.MOUSE_UP, this.EndScaleRect);
this.dispatchEvent(new Event(SelectRectangle.SELECTED));
}
// drag rectangle
public function InitDragEvent():void
{
this.onlayer.addEventListener(MouseEvent.MOUSE_DOWN, this.StartDragRect);
}
private function StartDragRect(e:MouseEvent):void
{
if(this.isScaleable)
return;
this.dragX = this.target.mouseX - this.drawRect.x;
this.dragY = this.target.mouseY - this.drawRect.y;
this.target.addEventListener(MouseEvent.MOUSE_MOVE, this.DragingRect);
this.target.addEventListener(MouseEvent.MOUSE_UP, this.EndDragEvent);
}
private function DragingRect(e:MouseEvent):void
{
this.drawRect = new Rectangle(this.target.mouseX - this.dragX,this.target.mouseY - this.dragY,this.drawRect.width, this.drawRect.height);
this.onlayer.graphics.clear();
this.onlayer.graphics.lineStyle(1,this.lineColor,1);
this.onlayer.graphics.beginFill(this.fillColor,this.fillAlpha);
this.onlayer.graphics.drawRect(this.drawRect.x,this.drawRect.y,this.drawRect.width,this.drawRect.height);
this.onlayer.graphics.endFill();
this.scaleButton.x = this.drawRect.x+this.drawRect.width;
this.scaleButton.y = this.drawRect.y+this.drawRect.height;
e.updateAfterEvent();
}
private function EndDragEvent(e:MouseEvent):void
{
this.target.removeEventListener(MouseEvent.MOUSE_MOVE, this.DragingRect);
this.target.removeEventListener(MouseEvent.MOUSE_UP, this.EndDragEvent);
this.dispatchEvent(new Event(SelectRectangle.SELECTED));
}
// cancel selected box
public function Cancel():void
{
this.onlayer.graphics.clear();
this.onlayer.removeEventListener(MouseEvent.MOUSE_DOWN, this.StartDragRect);
this.scaleButton.removeEventListener(MouseEvent.MOUSE_DOWN, this.StartScaleRect);
this.onlayer.removeChild(this.scaleButton);
this.isSelectRectangleFinished = false;
}
}
}
//选取框
package com.moorwind.imageprocesser.utils
{
import com.moorwind.imageprocesser.ui.ScaleButton;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import flash.net.URLLoader;
public class SelectRectangle extends URLLoader
{
private var target:Sprite
private var onlayer:Sprite;
private var startX:Number;
private var startY:Number;
private var dragX:Number;
private var dragY:Number;
private var drawRect:Rectangle;
private var scaleButton:ScaleButton;
public static const SELECTED:String = "selected";
public var lineColor:int = 0x0099FF;
public var fillColor:int = 0x0099FF;
public var fillAlpha:Number = 0.1;
public var isSelectRectangleFinished:Boolean = false;
public var isScaleable:Boolean = false;
public function SelectRectangle(target:Sprite, onlayer:Sprite)
{
this.target = target;
this.onlayer = onlayer;
this.onlayer.buttonMode = true;
}
//get selected rectangle
public function get selectRectangle():Rectangle
{
return this.isSelectRectangleFinished ? this.drawRect : null;
}
// initial rectangle
public function InitSelectRectangle():void
{
if(this.isSelectRectangleFinished)
return;
this.target.addEventListener(MouseEvent.MOUSE_DOWN, this.StartDrawRect);
}
private function StartDrawRect(e:MouseEvent):void
{
this.startX = this.target.mouseX;
this.startY = this.target.mouseY;
this.target.addEventListener(MouseEvent.MOUSE_MOVE, this.DrawingRect);
this.target.addEventListener(MouseEvent.MOUSE_UP, this.EndDrawRect);
}
private function DrawingRect(e:MouseEvent):void
{
this.drawRect = new Rectangle(this.startX,this.startY,this.target.mouseX - this.startX,this.target.mouseY - this.startY);
this.onlayer.graphics.clear();
this.onlayer.graphics.lineStyle(1,this.lineColor,1);
this.onlayer.graphics.beginFill(this.fillColor,this.fillAlpha);
this.onlayer.graphics.drawRect(this.drawRect.x,this.drawRect.y,this.drawRect.width,this.drawRect.height);
this.onlayer.graphics.endFill();
e.updateAfterEvent();
}
private function EndDrawRect(e:MouseEvent):void
{
this.isSelectRectangleFinished = true;
this.target.removeEventListener(MouseEvent.MOUSE_DOWN, this.StartDrawRect);
this.target.removeEventListener(MouseEvent.MOUSE_MOVE, this.DrawingRect);
this.target.removeEventListener(MouseEvent.MOUSE_UP, this.EndDrawRect);
this.scaleButton = new ScaleButton();
this.onlayer.addChild(this.scaleButton);
this.scaleButton.x = this.drawRect.x+this.drawRect.width;
this.scaleButton.y = this.drawRect.y+this.drawRect.height;
this.dispatchEvent(new Event(SelectRectangle.SELECTED));
this.StartScaleButton();
this.InitDragEvent();
}
// scale rectangle
public function StartScaleButton():void
{
this.scaleButton.addEventListener(MouseEvent.MOUSE_DOWN, this.StartScaleRect);
}
private function StartScaleRect(e:MouseEvent):void
{
this.isScaleable = true;
this.target.addEventListener(MouseEvent.MOUSE_MOVE, this.ScalingRect);
this.target.addEventListener(MouseEvent.MOUSE_UP, this.EndScaleRect);
}
private function ScalingRect(e:MouseEvent):void
{
this.drawRect = new Rectangle(this.drawRect.x,this.drawRect.y,this.target.mouseX - this.drawRect.x,this.target.mouseY - this.drawRect.y);
this.onlayer.graphics.clear();
this.onlayer.graphics.lineStyle(1,this.lineColor,1);
this.onlayer.graphics.beginFill(this.fillColor,this.fillAlpha);
this.onlayer.graphics.drawRect(this.drawRect.x,this.drawRect.y,this.drawRect.width,this.drawRect.height);
this.onlayer.graphics.endFill();
this.scaleButton.x = this.drawRect.x+this.drawRect.width;
this.scaleButton.y = this.drawRect.y+this.drawRect.height;
e.updateAfterEvent();
}
private function EndScaleRect(e:MouseEvent):void
{
this.isScaleable = false;
this.target.removeEventListener(MouseEvent.MOUSE_MOVE, this.ScalingRect);
this.target.removeEventListener(MouseEvent.MOUSE_UP, this.EndScaleRect);
this.dispatchEvent(new Event(SelectRectangle.SELECTED));
}
// drag rectangle
public function InitDragEvent():void
{
this.onlayer.addEventListener(MouseEvent.MOUSE_DOWN, this.StartDragRect);
}
private function StartDragRect(e:MouseEvent):void
{
if(this.isScaleable)
return;
this.dragX = this.target.mouseX - this.drawRect.x;
this.dragY = this.target.mouseY - this.drawRect.y;
this.target.addEventListener(MouseEvent.MOUSE_MOVE, this.DragingRect);
this.target.addEventListener(MouseEvent.MOUSE_UP, this.EndDragEvent);
}
private function DragingRect(e:MouseEvent):void
{
this.drawRect = new Rectangle(this.target.mouseX - this.dragX,this.target.mouseY - this.dragY,this.drawRect.width, this.drawRect.height);
this.onlayer.graphics.clear();
this.onlayer.graphics.lineStyle(1,this.lineColor,1);
this.onlayer.graphics.beginFill(this.fillColor,this.fillAlpha);
this.onlayer.graphics.drawRect(this.drawRect.x,this.drawRect.y,this.drawRect.width,this.drawRect.height);
this.onlayer.graphics.endFill();
this.scaleButton.x = this.drawRect.x+this.drawRect.width;
this.scaleButton.y = this.drawRect.y+this.drawRect.height;
e.updateAfterEvent();
}
private function EndDragEvent(e:MouseEvent):void
{
this.target.removeEventListener(MouseEvent.MOUSE_MOVE, this.DragingRect);
this.target.removeEventListener(MouseEvent.MOUSE_UP, this.EndDragEvent);
this.dispatchEvent(new Event(SelectRectangle.SELECTED));
}
// cancel selected box
public function Cancel():void
{
this.onlayer.graphics.clear();
this.onlayer.removeEventListener(MouseEvent.MOUSE_DOWN, this.StartDragRect);
this.scaleButton.removeEventListener(MouseEvent.MOUSE_DOWN, this.StartScaleRect);
this.onlayer.removeChild(this.scaleButton);
this.isSelectRectangleFinished = false;
}
}
}
view plaincopy to clipboardprint?
//剪裁图像
package com.moorwind.imageprocesser.edit
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Rectangle;
public class CutImage
{
public static function Cut(data:Bitmap, rect:Rectangle):Bitmap
{
var bitmapdata:BitmapData = data.bitmapData;
var retdata:BitmapData = new BitmapData(rect.width, rect.height, false);
retdata.copyPixels(bitmapdata,rect,new Point(0,0));
return new Bitmap(retdata);
}
}
}
发表评论
-
haXe是什么?
2016-01-04 10:50 1083haXe是什么? haXe是一种编程语言,官方网站在 ... -
用EA类图生成AS3代码
2008-10-15 16:18 2729EA(Enterprise Architect)是支持多种流 ... -
变形实例-source
2008-10-15 12:46 1559涂抹原理 橡皮擦原理 import flash.geom.P ... -
actionScript 3.0 图片裁剪及旋转
2008-10-10 12:54 5968package com.wdxc { /** ... -
Flash(AS3)读取Excel文件
2008-10-09 13:29 5191var excelXml:XML; var loader=ne ... -
AS3 Loading的制作方法
2008-10-09 13:28 6083AS2的时候做LOADING有很多种方法,做起来也得心应手可是 ... -
让"Flash" 写文件(AS3)
2008-09-11 16:23 1807目前,出于安全考虑Flash不支持写文件的操作,在AS3的A ... -
AS3 中的 拖动 及 碰撞 检测
2008-09-11 16:11 2949没有press和release事件 hitTest()被分尸 ... -
As和js通信问题完全解析(解决addcallback失效的问题)
2008-09-11 16:10 3665as和js通信最早用的是fscommand,这个我就不说了,老 ... -
Flash CS3制作Fla形式的组件
2008-06-16 14:45 1404本文为大家介绍如何制作Flash CS3中的[*.fla]形 ... -
从界面入手 划分类
2008-06-15 19:25 1296如何将一个项目细化成各个类呢? 1 从一个项目的界面入手,按照 ... -
AS3-DisplayEffect组件
2008-06-14 20:40 2090[AS3]DisplayEffect组件【组件版本】:0.5【 ... -
KTooltip 工具提示组件
2008-06-14 20:38 1044发布一个小工具KTooltip 。这是0.9beta版,出发日 ... -
AS3.0写的一个滚动条【缓动效果】
2008-06-13 16:10 6400package { import flash.d ... -
一个简单的文本滚动条类 as3
2008-06-13 16:04 4402最近一直做会议与AS3有关项目今天花了点时间写了一个可以选择套 ... -
自定义滚动条类
2008-06-13 16:01 2097在平常的开发中,经常需要用到滚动条,今天将滚动条类整理了下,有 ... -
AS3加载机制
2008-06-13 15:03 2224摸了好一阵子,才弄明白AS3.0的加载机制.还是坚持自己的原则 ... -
写了一个Flash的Transition
2008-06-11 10:36 1755写了一个Flash的Transition package { ... -
JavaScript与ActionScript函数相互调用
2008-06-06 15:07 22881、在JavaScript中调用Flex( ... -
传参之事件代理
2008-06-05 10:23 1116有时候我们在调用事件侦听器的时候,需要给它传进相应的参数,这个 ...
相关推荐
我们将探讨MATLAB的基本图像处理概念、图像剪裁的原理以及相关的编程技巧。 首先,了解MATLAB中的图像处理基础。在MATLAB中,图像被存储为二维数组,通常是一个灰度图像或RGB三通道图像。灰度图像由一个二维矩阵...
在图像处理领域,批量剪裁是一项常见的任务,尤其在研究或数据分析中,当需要处理大量图像时,手动剪裁每一张图片将非常耗时。Matlab作为一种强大的数值计算和图形处理环境,提供了丰富的图像处理工具箱,使得我们...
图片初步处理,包括图片的读入,灰度图像转换,图片剪裁。
图像处理论文剪裁不同处理图像的同一位置的图像块,可手动设置图像块的尺寸。MATLAB程序。
3. **图像处理**:在AS3中,可能使用了像`BitmapData`类来处理图像数据,实现剪裁功能。用户选择的图像会被读取、裁剪,然后以适合的格式发送到服务器。 4. **.NET Web服务或API**:在服务器端,.NET代码接收来自AS...
基于MATLAB的GUI图像处理程序设计实现图像的打开、剪裁、保存
"用VB写高效的图像处理程序" 图像处理是计算机视觉和图形学中非常重要的一部分,它涉及到图像的读取、处理和保存。在VB中,图像处理可以通过使用PSet和SetPixel函数来实现,但是这些函数的执行速度非常慢,特别是在...
QQ自定义图像剪裁是一种常见的图像处理功能,广泛应用于社交应用如QQ中,允许用户根据自己的需求裁剪图片,以创建个性化头像或其他用途。在本文中,我们将深入探讨这一功能涉及的技术点、实现步骤以及可能遇到的问题...
《VC++图像处理程序设计》是一本深入探讨VC++在图像处理领域的专著,而提供的压缩包文件包含了这本书配套的源代码,这对于学习和实践VC++图像处理技术来说是宝贵的资源。VC++作为Microsoft开发的一款强大的C++集成...
这个“php图像处理类”可能是基于其中之一或两者封装的,以提供更高层次的接口和更便捷的用法。 1. 图像缩放:图像缩放是调整图像大小以适应不同的显示需求。这个类可能包含一个方法,接受原始图像路径和目标尺寸,...
3. 使用控件:在Form上添加控件,如TDrawImage,然后在代码中调用相关方法和属性进行图像处理。 4. 编写处理逻辑:根据需要编写处理图像的代码,例如使用滤镜函数、变换函数等。 总的来说,Draw_hss图形图像处理库...
通过刘定生老师的《数字图像处理与分析》课程,学生不仅能掌握图像处理的基本理论和技术,还能了解到该领域的前沿动态,为今后从事相关工作或研究打下坚实基础。同时,课件中的实例和习题将帮助学生将理论知识转化为...
在图像处理领域,MATLAB是一种常用的工具,因其强大的矩阵运算能力和丰富的图像处理库而备受青睐。这个名为"图像处理各种算法matlab"的压缩包很可能包含了一系列基于MATLAB实现的图像处理实验,这些实验覆盖了图像...
在数字图像处理领域,图像剪裁是一项基础且实用的技术,它允许用户从一张图片中选择并提取出特定区域,以聚焦于感兴趣的细节或去除不必要部分。通过精巧的图像剪裁,我们可以创建更加紧凑、突出主题的视觉作品,无论...
数字图像处理是利用计算机及其它相关知识,对图像进行一系列的运算和处理的综合性学科。该学科理论较为复杂,掌握其原理对于图像处理领域的学者至关重要。由于目前的图像处理软件往往将算法封装起来,不利于学习和...
在IT行业中,图像处理是一项重要的技术,特别是在软件开发领域,如视觉艺术、计算机视觉和游戏开发等。"VC++图像处理源码"是针对初学者的一份宝贵资源,它源自吕凤军的《数字图象处理编程入门》一书。这本书通过实际...
在图像处理领域,BMP(Bitmap)是一种常见的位图文件格式,用于存储未经压缩的图像数据。本资源包集合了BMP图像的灰度化、缩放和剪裁等核心处理函数,对于理解和实践基本的图像操作具有重要作用。这些功能在计算机...
【标题】"Vb 图像处理"涉及到的知识点主要集中在使用Visual Basic (Vb) 进行图像处理软件的开发。Visual Basic 是一种由微软公司推出的面向对象的编程语言,常用于开发桌面应用程序,因其易学性和丰富的控件库而受到...
消隐算法处理的是如何在3D场景中正确地隐藏那些被其他对象遮挡的物体部分,使得图像看起来更加真实。剪裁则涉及到将超出视口范围的3D对象部分剔除,以减少不必要的计算,提高渲染效率。 消隐算法主要有深度排序法...
其高效、灵活的特点使其成为Python开发中的图像处理首选工具之一。 总的来说,Python-thumbor是一个强大的图像处理解决方案,它的智能裁剪、尺寸重设和翻转功能使得它在处理图像时既高效又精确。通过理解其核心功能...