Apache flex 如何在Flex中实现透明橡皮擦工具?
如何在Flex中实现橡皮擦,以便在mx:Image上进行橡皮擦时使区域透明?也许您可以尝试在BitmapData对象中绘制图像,然后使用函数setPixel32: 例如:Apache flex 如何在Flex中实现透明橡皮擦工具?,apache-flex,Apache Flex,如何在Flex中实现橡皮擦,以便在mx:Image上进行橡皮擦时使区域透明?也许您可以尝试在BitmapData对象中绘制图像,然后使用函数setPixel32: 例如: setPixel32 (coordX, coordY, 0x60FF0000); 其中0x60FF0000为: 60(阿尔法) FF(红色) 00(绿色) 00(蓝色) 从我见过的大多数擦除功能来看,我承认没有那么多,它不会使某些东西透明(改变alpha),而是用背景色绘制 YMMV我的方法是将黑色遮罩图像添加到图像组件中
setPixel32 (coordX, coordY, 0x60FF0000);
其中0x60FF0000为:
- 60(阿尔法)
- FF(红色)
- 00(绿色)
- 00(蓝色)
YMMV我的方法是将黑色遮罩图像添加到图像组件中(通过“遮罩”属性),它最初对图像没有影响,然后在用户在图像中单击/拖动的任何位置将白色绘制到遮罩图像中。希望有帮助。
受保护的函数myImage\u completeHandler(事件:事件):void
protected function myImage_completeHandler(event:Event):void
{
// TODO Auto-generated method stub
trace("file loaded");
var tempBdData:BitmapData = new BitmapData(myImage.contentWidth,myImage.contentHeight,true);
tempBdData.draw(myImage);
(myImage.content as Bitmap).bitmapData = tempBdData;
}
]]>
</mx:Script>
<mx:Image
id="myImage"
source="http://www.google.com/images/logos/ps_logo2.png"
complete="myImage_completeHandler(event)"
mouseDown="(myImage.content as Bitmap).bitmapData.setPixel32(event.localX,event.localY,0x00000000)"/>
{
//TODO自动生成的方法存根
跟踪(“文件加载”);
var tempBdData:BitmapData=新的BitmapData(myImage.contentWidth,myImage.contentHeight,true);
tempBdData.draw(myImage);
(myImage.content作为位图)。bitmapData=tempBdData;
}
]]>
如果您有一个图像,例如在单独的代码回答中发布的示例,则图像的组成部分中有一个BitmapData实例。