[求助]版主快来,如何获取一图片内还有黑色的矩形
时间:2011-07-07
来源:互联网
如题,我用getColorBoundsRect不准确的,有没有谁遇到过这种问题。
[local]图1[/local]
这是一个字的时候,不管是什么字,都是一半。
[local]图2[/local]
这是两个字的时候,有时候好的,有时候会有一点得不到。
1.jpg (1.81 KB)
2.jpg (2.57 KB)
[local]图1[/local]
这是一个字的时候,不管是什么字,都是一半。
[local]图2[/local]
这是两个字的时候,有时候好的,有时候会有一点得不到。
附件

2011-7-7 11:19
图1

2011-7-7 11:19
图2
作者: poppyvivi 发布时间: 2011-07-07
复制内容到剪贴板
import flash.display.BitmapData;
import flash.geom.Rectangle;
var txt:TextField = new TextField();
txt.text = "我们你说啊测试啊"
addChild(txt)
var bmd:BitmapData = new BitmapData(txt.width,txt.height, true, 0xFFFFFF);
bmd.draw(txt);
var bm:Bitmap = new Bitmap(bmd);
bm.x = 100
addChild(bm);
var maskColor:uint = 0xffFFFFFF;
var color:uint = 0xff000000;
var redBounds:Rectangle = bmd.getColorBoundsRect(maskColor, color, true);
trace(redBounds); // (x=0, y=0, w=80, h=20)
var sp1:Sprite = new Sprite();
sp1.graphics.lineStyle(1,0xff0000);
sp1.graphics.beginFill(0xffff00,0);
trace(bm.x,bm.y,redBounds.width,redBounds.height)
sp1.graphics.drawRect(bm.x,bm.y,redBounds.width,redBounds.height);
sp1.graphics.endFill()
sp1.x = redBounds.x;
sp1.y = redBounds.y;
addChild(sp1);
trace(sp1)
代码:
import flash.display.Bitmap;import flash.display.BitmapData;
import flash.geom.Rectangle;
var txt:TextField = new TextField();
txt.text = "我们你说啊测试啊"
addChild(txt)
var bmd:BitmapData = new BitmapData(txt.width,txt.height, true, 0xFFFFFF);
bmd.draw(txt);
var bm:Bitmap = new Bitmap(bmd);
bm.x = 100
addChild(bm);
var maskColor:uint = 0xffFFFFFF;
var color:uint = 0xff000000;
var redBounds:Rectangle = bmd.getColorBoundsRect(maskColor, color, true);
trace(redBounds); // (x=0, y=0, w=80, h=20)
var sp1:Sprite = new Sprite();
sp1.graphics.lineStyle(1,0xff0000);
sp1.graphics.beginFill(0xffff00,0);
trace(bm.x,bm.y,redBounds.width,redBounds.height)
sp1.graphics.drawRect(bm.x,bm.y,redBounds.width,redBounds.height);
sp1.graphics.endFill()
sp1.x = redBounds.x;
sp1.y = redBounds.y;
addChild(sp1);
trace(sp1)
作者: libins 发布时间: 2011-07-07
你说的这个,是不是就是获取文本里 黑色像素的矩形?
作者: libins 发布时间: 2011-07-07
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28