如何在应用程序中创建桶填充工具?
如何在 Flex 的油漆应用中实现桶填充工具?
case FILL:
var b:BitmapData = new BitmapData(width, height);
b.draw(this);
b.lock();
var from:uint = b.getPixel(x,y);
var q:Array = [];
var xx:int;
var yy:int;
var w:int = b.width;
var h:int = b.height;
q.push(y*w + x);
while (q.length != 0) {
var xy:int = q.shift();
xx = xy % w;
yy = (xy - xx) / w;
if (b.getPixel(xx,yy) == from) {
b.setPixel(xx,yy,SolidColorStroke(stroke).color);
if (xx != 0) q.push(xy-1);
if (xx != w-1) q.push(xy+1);
if (yy != 0) q.push(xy-w);
if (yy != h-1) q.push(xy+w);
}
}
b.unlock(null);
break;
阿卜杜勒·哈利克
how can i implement a bucket fill tool in paint application in flex?
case FILL:
var b:BitmapData = new BitmapData(width, height);
b.draw(this);
b.lock();
var from:uint = b.getPixel(x,y);
var q:Array = [];
var xx:int;
var yy:int;
var w:int = b.width;
var h:int = b.height;
q.push(y*w + x);
while (q.length != 0) {
var xy:int = q.shift();
xx = xy % w;
yy = (xy - xx) / w;
if (b.getPixel(xx,yy) == from) {
b.setPixel(xx,yy,SolidColorStroke(stroke).color);
if (xx != 0) q.push(xy-1);
if (xx != w-1) q.push(xy+1);
if (yy != 0) q.push(xy-w);
if (yy != h-1) q.push(xy+w);
}
}
b.unlock(null);
break;
Abdul Khaliq
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过 Bitmapdata.floodFill ?
Have you tried with Bitmapdata.floodFill?