actionscript3保存为jpg格式

package  com.wdxc  ... {
    
import com.wdxc.util.JPGEncoder;
    
import flash.net.URLRequest; 
    
import flash.net.URLRequestMethod ;
      
    
/** *//**
    * 与服务端通信
    * 
@author luqinglong
    
*/

    
public class ImageService ...{
        
        
private var url:String = "http://192.168.0.211:8080/photo/PhotoEditServlet?photoid=267005" ;
        
        
public function ImageService() ...{
            
        }

              
        
/** *//**  
         * 对图片编码并提交给服务端保存。
         * 
@param bitmapdata  
         * 
@param url       
         
*/
         
        
public function submit(bitmapdata:BitmapData,url:String):void ...{
            var request:URLRequest 
= new URLRequest(url);  
              
            
//编码成图片格式流
            var encoder:JPGEncoder = new JPGEncoder(80); 
            var bytes:ByteArray 
= encoder.encode(bitmapdata);      
            
            request.method 
= URLRequestMethod.POST; 
            request.data 
= bytes ;   
                     
            
//设置成文件流形式
            request.contentType = "application/octet-stream"

            var loader:URLLoader 
= new URLLoader();                  
            loader.load(request) ;            
                  
            loader.addEventListener(Event.COMPLETE, completeHandler) ;  
        }
        
                             
        
private function completeHandler(e:Event):void ...{
            e.currentTarget.removeEventListener(Event.COMPLETE, completeHandler);   
        }
  
    }

    
}

你可能感兴趣的:(.net,Flash)