Flash Actionscript 3.0 位图九宫格切片代码

来源:http://bbs.9ria.com/thread-235526-1-1.html

package cn.flashk.controls.support{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.geom.Matrix;
	import flash.geom.Point;
	import flash.geom.Rectangle;

	/**
	* <p>Scale9GridBitmap 用来创建位图的九宫格缩放。(因为flash本身的九宫格缩放并不支持位图,只支持矢量)</p>
	* 
	* 要使用位图的九宫格,请先传递原始的图像到sourceBitmapData属性,scale9GridBitmap.sourceBitmapData = bitmapData实例
	* 然后直接设置width和height属性。(此时scaleX和scaleY始终为1,set width和set height函数已经被重写)。
	* 虽然你仍然可以设置scale横向缩放和竖向缩放,不过不建议使用设置scaleX和scaleY属性缩放。要使用scaleX而又要开启九宫格,请使用 b.width = b.width 乘以 b.scaleX这样的语法。
	*/

	public class Scale9GridBitmap extends Bitmap {
		/**
		* 九宫格左边竖线与0坐标的距离
		*/
		public var leftLineSpace:uint = 8;
		/**
		* 九宫格右边竖线与图像最右像素的距离
		*/
		public var rightLineSpace:uint = 8;
		/**
		* 九宫格上面横线与0坐标的距离
		*/
		public var topLineSpace:uint = 6;
		/**
		* 九宫格下面横线与图像最下像素的距离
		*/
		public var bottomLineSpace:uint = 6;
		/**
		* 控制再拉伸九宫格位图时是否对中间的部分开启平滑处理,默认关闭,开启将获得更好的渐变效果,设置为 true 的情况下绘制位图要比在设置为 false 的情况下执行相同操作更为缓慢,请注意此参数与smoothing属性的区别,smoothing是指控制在整个位图缩放时是否进行平滑处理。
		* smoothing在这里只影响小数坐标时是否平滑处理,因为Scale9GridBitmap的在重设宽高时scaleX和scaleY始终为1(set width和set height函数已经被重写,但你仍然可以自己设置scaleX,此时smoothing会有效果)
		* 
		* <p>修改scaleSmoothing只会在下一次更改宽高时生效,并不会立即刷新图像,如果需要立即刷新,请调用update函数</p>
		* 
		* @see #update()
		*/
		public var scaleSmoothing:Boolean = false;

		protected var sourceBD:BitmapData;
		protected var _width:uint=0;
		protected var _height:uint=0;
		protected var bd:BitmapData;

		public function Scale9GridBitmap() {
		}

		/**
		* 设置Scale9GridBitmap的原始未缩放的源数据,可以与其他 Bitmap 共用一个 Bitmapdata。因为Scale9GridBitmap在重设宽高需要重新计算bitmapdata数据,需要以此属性的数据做参考,Scale9GridBitmap并不会修改此属性中的像素数据。只会修改自身bitmapdata属性的数据。
		*/
		public function set sourceBitmapData(value:BitmapData):void {
			sourceBD = value;
			this.bitmapData = sourceBD;
			if (_height==0) {
				_height = sourceBD.height;
			}
			if (_width == 0) {
				_width = sourceBD.width;
			}
		}

		public function useSourceSize():void {
			this.bitmapData = sourceBD;
			_height = sourceBD.height;
			_width = sourceBD.width;
		}

		/**
		* 更改Scale9GridBitmap的宽度,修改此值将重新计算Scale9GridBitmap的bitmapData数据,如果height值与源图像相同,只修改width将采用3分法加速
		* 
		* @see #scaleGrid3()
		* @see #update()
		*/
		override public function set width(value:Number):void {
			if (uint(value) == _width) {
				return;
			}
			_width = uint(value);
			if (sourceBD == null) {
				return;
			}
			if (_width == sourceBD.width && _height == sourceBD.height) {
				this.bitmapData = sourceBD;
				return;
			}
			if (_height == sourceBD.height) {
				scaleGrid3();
			} else {
				scaleGrid9();
			}
		}

		/**
		* 更改Scale9GridBitmap的高度,修改此值将重新计算Scale9GridBitmap的bitmapData数据,如果width值与源图像相同,只修改height将采用3分法加速
		* 
		* @see #scaleGrid3V()
		* @see #update()
		*/
		override public function set height(value:Number):void {
			if (uint(value) == _height) {
				return;
			}
			_height = uint(value);
			if (_width == sourceBD.width && _height == sourceBD.height) {
				this.bitmapData = sourceBD;
				return;
			}
			if (_width == sourceBD.width) {
				scaleGrid3V();
			} else {
				scaleGrid9();
			}
		}

		/**
		* 立即重新计算图像,如果sourceBitmapData的数据有更新,调用此方法立即刷新Scale9GridBitmap与sourceBitmapData同步,请注意Scale9GridBitmap的bitmapData始终与sourceBitmapData是两份不同的数据和对象
		*/
		public function update():void {
			if (sourceBD && _width == sourceBD.width && _height == sourceBD.height) {
				this.bitmapData = sourceBD;
				return;
			}
			if (sourceBD && _width == sourceBD.width) {
				scaleGrid3V();
			} else if (sourceBD && _height == sourceBD.height) {
				scaleGrid3();
			} else {
				scaleGrid9();
			}
		}

		/**
		* 横向3分格启用加速
		*/
		protected function scaleGrid3():void {
			if (bd != null) {
				bd.dispose();
			}
			bd = new BitmapData(_width,_height,true,0);
			bd.copyPixels( sourceBD,new Rectangle(0,0,leftLineSpace,_height),new Point(0,0) );
			var tmpBD:BitmapData;
			tmpBD = new BitmapData(sourceBD.width-leftLineSpace-rightLineSpace,sourceBD.height,true,0);
			tmpBD.copyPixels(sourceBD,new Rectangle(leftLineSpace,0,tmpBD.width,tmpBD.height),new Point(0,0) );
			var mat:Matrix = new Matrix();
			var sca:Number = (_width-leftLineSpace-rightLineSpace)/(sourceBD.width-leftLineSpace-rightLineSpace);
			mat.scale(sca,1);
			mat.tx = leftLineSpace;
			bd.draw(tmpBD,mat,null,null,new Rectangle(leftLineSpace,0,_width-leftLineSpace-rightLineSpace,_height),scaleSmoothing );
			bd.copyPixels( sourceBD,new Rectangle(sourceBD.width-rightLineSpace,0,rightLineSpace,_height),new Point(_width-rightLineSpace,0) );
			this.bitmapData = bd;
			tmpBD.dispose();
		}

		/**
		* 竖向3分格启用加速
		*/
		protected function scaleGrid3V():void {
			if (bd != null) {
				bd.dispose();
			}
			bd = new BitmapData(_width,_height,true,0);
			bd.copyPixels( sourceBD,new Rectangle(0,0,_width,_height),new Point(0,0) );
			var tmpBD:BitmapData;
			tmpBD = new BitmapData(sourceBD.width,sourceBD.height-topLineSpace-bottomLineSpace,true,0);
			tmpBD.copyPixels(sourceBD,new Rectangle(0,topLineSpace,tmpBD.width,tmpBD.height),new Point(0,0) );
			var mat:Matrix = new Matrix();
			var sca:Number = (_height-topLineSpace-bottomLineSpace)/(sourceBD.height-topLineSpace-bottomLineSpace);
			mat.scale(1,sca);
			mat.ty = topLineSpace;
			bd.draw(tmpBD,mat,null,null,new Rectangle(0,topLineSpace,_width,_height-topLineSpace-bottomLineSpace),scaleSmoothing );
			bd.copyPixels( sourceBD,new Rectangle(0,sourceBD.height-bottomLineSpace,_width,bottomLineSpace),new Point(0,_height-bottomLineSpace) );
			this.bitmapData = bd;
			tmpBD.dispose();
		}

		protected function scaleGrid9():void {
			if (bd != null) {
				bd.dispose();
			}
			var tmpBD:BitmapData;
			bd = new BitmapData(_width,_height,true,0);
			var scaX:Number=(_width-leftLineSpace-rightLineSpace)/(sourceBD.width-leftLineSpace-rightLineSpace);
			var scaY:Number = (_height-topLineSpace-bottomLineSpace)/(sourceBD.height-topLineSpace-bottomLineSpace);
			var mat:Matrix;
			tmpBD = new BitmapData(sourceBD.width-leftLineSpace-rightLineSpace,topLineSpace,true,0);
			tmpBD.copyPixels(sourceBD,new Rectangle(leftLineSpace,0,tmpBD.width,tmpBD.height),new Point(0,0) );
			mat= new Matrix();
			mat.scale(scaX,1);
			mat.tx = leftLineSpace;
			bd.draw(tmpBD,mat,null,null,new Rectangle(leftLineSpace,0,_width-leftLineSpace-rightLineSpace,topLineSpace),scaleSmoothing );
			if (bottomLineSpace == topLineSpace) {
				tmpBD.fillRect(new Rectangle(0,0,tmpBD.width,tmpBD.height),0);
			} else {
				tmpBD.dispose();
				tmpBD = new BitmapData(sourceBD.width-leftLineSpace-rightLineSpace,bottomLineSpace,true,0);
			}
			tmpBD.copyPixels(sourceBD,new Rectangle(leftLineSpace,sourceBD.height-bottomLineSpace,tmpBD.width,tmpBD.height),new Point(0,0) );
			mat.ty = _height-bottomLineSpace;
			bd.draw(tmpBD,mat,null,null,new Rectangle(leftLineSpace,_height-bottomLineSpace,_width-leftLineSpace-rightLineSpace,bottomLineSpace),scaleSmoothing );
			mat= new Matrix();
			mat.scale(1,scaY);
			tmpBD.dispose();
			tmpBD = new BitmapData(leftLineSpace,sourceBD.height-topLineSpace-bottomLineSpace,true,0);
			tmpBD.copyPixels(sourceBD,new Rectangle(0,topLineSpace,tmpBD.width,tmpBD.height),new Point(0,0) );
			mat.ty = topLineSpace;
			bd.draw(tmpBD,mat,null,null,new Rectangle(0,topLineSpace,leftLineSpace,_height-topLineSpace-bottomLineSpace),scaleSmoothing );
			if (rightLineSpace == leftLineSpace) {
				tmpBD.fillRect(new Rectangle(0,0,tmpBD.width,tmpBD.height),0);
			} else {
				tmpBD.dispose();
				tmpBD = new BitmapData(rightLineSpace,sourceBD.height-topLineSpace-bottomLineSpace,true,0);
			}
			tmpBD.copyPixels(sourceBD,new Rectangle(sourceBD.width-rightLineSpace,topLineSpace,tmpBD.width,tmpBD.height),new Point(0,0) );
			mat.tx = _width-rightLineSpace;
			bd.draw(tmpBD,mat,null,null,new Rectangle(_width-rightLineSpace,topLineSpace,rightLineSpace,_height-topLineSpace-bottomLineSpace),scaleSmoothing );
			mat = new Matrix();
			mat.scale(scaX,scaY);
			tmpBD.dispose();
			tmpBD = new BitmapData(sourceBD.width-leftLineSpace-rightLineSpace,sourceBD.height-topLineSpace-bottomLineSpace,true,0);
			tmpBD.copyPixels(sourceBD,new Rectangle(leftLineSpace,topLineSpace,tmpBD.width,tmpBD.height),new Point(0,0) );
			mat.tx = leftLineSpace;
			mat.ty = topLineSpace;
			bd.draw(tmpBD,mat,null,null,new Rectangle(leftLineSpace,topLineSpace,_width-leftLineSpace-rightLineSpace,_height-topLineSpace-bottomLineSpace),scaleSmoothing );
			tmpBD.dispose();
			bd.copyPixels(sourceBD,new Rectangle(0,0,leftLineSpace,topLineSpace),new Point(0,0) );
			bd.copyPixels(sourceBD,new Rectangle(0,sourceBD.height-bottomLineSpace,leftLineSpace,bottomLineSpace),new Point(0,_height-bottomLineSpace) );
			bd.copyPixels(sourceBD,new Rectangle(sourceBD.width-rightLineSpace,0,rightLineSpace,topLineSpace),new Point(_width-rightLineSpace,0) );
			bd.copyPixels(sourceBD,new Rectangle(sourceBD.width-rightLineSpace,sourceBD.height-bottomLineSpace,rightLineSpace,bottomLineSpace),new Point(_width-rightLineSpace,_height-bottomLineSpace) );
			this.bitmapData = bd;
		}

	}
}

 

WIN8 错误代码:720

来源:http://tieba.baidu.com/p/3261639822

在系统运行中使用 CMD 打开命令行模式。
使用REGEDIT 打开注册表编辑器。
找到以下注册表子项:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}
请逐个查找每个子项,找到在右侧“DriverDesc”值数据为 “WAN微型端口(网络监视器)”的子项。(同理找到IP,IPV6)
将每个找到的子项中的“Characteristics” 值数据从29修改为9。(注意你要找到3个进行修改,因为你有三个感叹号)
此时,在系统设备管理器中就可以将问题项卸掉了。
再点击扫描,感叹号消失,拨号错误720也没有了

注:可能需要重启

解决 Windows 10 强制安装更新问题

Windows10不再允许关闭系统自动更新,也不允许选择是否更新微软提供的硬件驱动程序。
这造成了很多用户升级到Windows10,安装好驱动后(尤其显卡),不一会就被自动更新推送的驱动程序替换成微软的版本,让人烦恼。
事实证明,高级系统设置->系统属性->硬件->设备安装设置,”从不安装来自Windows更新的驱动程序软件“选项,不能有效阻止自动安装。
好在微软为有需要禁止自动更新的用户,提供了单独的工具。

解决方法:

1、(如果要隐藏的更新已经安装,需要先卸载该更新并重新启动计算机)
2、下载文章末尾的工具。如图所示,运行该工具,勾选需要隐藏的更新,一路下一步即可。

Show or Hide updates

傲游截图20150930232535

傲游截图20150930233038

傲游截图20150930235123
Show or Hide updates

相关页面:https://support.microsoft.com/en-us/kb/3073930
软件地址:http://download.microsoft.com/download/F/2/2/F22D5FDB-59CD-4275-8C95-1BE17BF70B21/wushowhide.diagcab

Java (Android) 学习笔记

(以下内容为AIDE)

数据类型有关
System.out.println(“Result: “+3.1415+2)  //Result: 3.14152
System.out.println(“Result: “+(3.1415+2))
//Result: 5.141500000000001
System.out.println(“Result: “+(3.1415F+2F))
//Result: 5.1415
System.out.println(“Result: “+(3/2))
//Result: 1
System.out.println(“Result: “+(3.0/2.0)
//Result: 1.5
System.out.println(“Result: “+(3F/2F)
//Result: 1.5

类型转换
String.valueOf(); //

设置输入法类型
editText.setInputType(EditorInfo.*);

设置焦点(下列三个属性必须同时设置)
editText.setFocusable(true);   
editText.setFocusableInTouchMode(true);
editText.requestFocus();

【解决方案】iebook黑屏怎么办? Zmaker 出错怎么办?

【 解决方案 】iebook黑屏怎么办
【 解决方案 】iebook黑屏怎么办

近期有不少网友出现打开iebook程序出现黑屏或打开Zmaker出错的问题。追根溯源,都是Adobe惹的祸——最新版的Adobe Flash Player 18版本存在Bug导致(截止18.0.0.160无此问题) 。现给出解决方案——卸载18版本,安装17旧版或更新的19版

继续阅读【解决方案】iebook黑屏怎么办? Zmaker 出错怎么办?

【iebook 超级精灵系列教程 2】制作片头

最近在群里看到有些人问如何让自己制作的flash片头在iebook里居中显示。印象中官方提供的帮助文档有说明的。

经过试验,个人觉得官方的制作介绍有些不清楚、不完善的地方,所以就自己写一篇供大家参考。如果有什么疏漏,请不吝赐教。: )

继续阅读【iebook 超级精灵系列教程 2】制作片头

修正 Hotel Booking 主题

最近需要制作一个酒店网站,好不容易找到了一个wordpress的主题——Hotel Booking。安装试用了下,感觉都不错。只是虽然找了汉化版1.0.1的主题包,但是有些地方仍然是乱码,在百度了相关错误信息(Warning: #1366)后,得出需要修改数据库里的编码(参阅这里)。觉得网上关于这方面的文章有点少,特此记录下。

打开phpMyAdmin,进入wp_hotel_info_master等表,将如下内容的排序规则改为utf8-general-ci即可。

wp_hotel_info_master 表结构
wp_hotel_info_master 表结构