码迷,mamicode.com
首页 > 其他好文 > 详细

在线签名,并保存到本地

时间:2014-06-11 09:05:38      阅读:268      评论:0      收藏:0      [点我收藏+]

标签:code   http   width   cti   os   new   

saveImgGroup的大小由里面的图片决定。

<s:Group  top="75" width="1440" height="830" horizontalCenter="0">
   <!--相片-->
   <s:Group id="saveImgGroup" horizontalCenter="0" verticalCenter="0">
    <s:BitmapImage id="signPhoto" maxWidth="1440" maxHeight="830" horizontalCenter="0"
       scaleMode="letterbox" source="http://121.0.0.1/baozhi/2.png" verticalCenter="0"/>
    <s:Group id="drawWords" width="{signPhoto.width}" height="{signPhoto.height}"
       horizontalCenter="0" verticalCenter="0"/>
   </s:Group>
   
  </s:Group>

 

 

注:saveBitmapData=new BitmapData(saveImgGroup.width,saveImgGroup.height,true,0);
   saveBitmapData.draw(saveImgGroup);

最后保存的图片的大小是由saveImgGroup.width,saveImgGroup.height决定的,而saveBitmapData.draw()会在saveImgGroup的左上角截取大小为

saveImgGroup.width,saveImgGroup.height的区域。

 

/**
   *在线保存图片
   * */
  private var saveBitmapData:BitmapData;
  private function saveBtnClickHandler(evt:MouseEvent):void
  {
   saveBitmapData=new BitmapData(saveImgGroup.width,saveImgGroup.height,true,0);
   saveBitmapData.draw(saveImgGroup);
   var imgByteArray:ByteArray=PNGEncoder.encode(saveBitmapData);
   var file:File=new File("E:\\PhotoAndSignature\\signImg\\100.png");
   var fs:FileStream=new FileStream();
   try
   {
    fs.open(file, FileMode.WRITE);
    fs.writeBytes(imgByteArray);
    fs.close();
   }
   catch (e:Error)
   {
    trace(e.message);
   }
  }

在线签名,并保存到本地,布布扣,bubuko.com

在线签名,并保存到本地

标签:code   http   width   cti   os   new   

原文地址:http://www.cnblogs.com/dongyl/p/3773174.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!