Packagede.popforge.imageprocessing.utils
Classpublic final class Publish

The Publish class provides methods to make saving of images very easy.



Public Methods
 MethodDefined by
  
sendToSocket(file:ByteArray, host:String, port:int):void
[static] Establishes a connection to a server and sends the file.
Publish
  
sendToWeb(file:ByteArray, url:String):void
[static] Sends a file to a given URL.
Publish
Method detail
sendToSocket()method
public static function sendToSocket(file:ByteArray, host:String, port:int):void

Establishes a connection to a server and sends the file. This is just a raw connection. Only the file will be send. There is also no handling for any errors at this point.

Parameters
file:ByteArray — Your encoded image.
 
host:String — The host you want to connect to.
 
port:int — The port on which the server is running (must be greater 1024).
sendToWeb()method 
public static function sendToWeb(file:ByteArray, url:String):void

Sends a file to a given URL. Therefore the POST method is used and the data is accessible as raw post data.

A simple PHP script to save an image you publish this way could be done like this:

   <?php
   $fp = fopen( 'image.png', 'wb' );
   fwrite( $fp, $GLOBALS[ 'HTTP_RAW_POST_DATA' ] );
   fclose( $fp );
   ?>
   
Parameters
file:ByteArray — Your encoded image.
 
url:String — The URL that will recieve the file.

Example
   var video: WebCam = new WebCam( 160, 120 );
   var image: Image = new Image( 160, 120, ImageFormat.RGB );
   
   image.loadBitmapData( video.getCurrentFrame(), true );
   
   Publish.sendToWeb( image.toPNG(), 'http://www.foo.com/bar.php' );