Search This Blog

Thursday, January 13, 2011

Photo Booth – Flash Webcam Image Capture PHP

http://blog.vamapaull.com/?p=355

import flash.display.Bitmap;
import flash.display.BitmapData;
import com.adobe.images.JPGEncoder;
 
var snd:Sound = new camerasound(); //new sound instance for the "capture" button click
 
var bandwidth:int = 0; // Maximum amount of bandwidth that the current outgoing video feed can use, in bytes per second.
var quality:int = 100; // This value is 0-100 with 1 being the lowest quality. 
 
var cam:Camera = Camera.getCamera();
cam.setQuality(bandwidth, quality);
cam.setMode(320,240,30,false); // setMode(videoWidth, videoHeight, video fps, favor area)
var video:Video = new Video();
video.attachCamera(cam);
video.x = 20;
video.y = 20;
addChild(video);
 
var bitmapData:BitmapData = new BitmapData(video.width,video.height);
 
var bitmap:Bitmap = new Bitmap(bitmapData);
bitmap.x = 360;
bitmap.y = 20;
addChild(bitmap);
 
capture_mc.buttonMode = true;
capture_mc.addEventListener(MouseEvent.CLICK,captureImage);
 
function captureImage(e:MouseEvent):void {
 snd.play();
 bitmapData.draw(video);
 save_mc.buttonMode = true;
 save_mc.addEventListener(MouseEvent.CLICK, onSaveJPG);
 save_mc.alpha = 1;
}
 
save_mc.alpha = .5;
 
function onSaveJPG(e:Event):void{
 var myEncoder:JPGEncoder = new JPGEncoder(100);
 var byteArray:ByteArray = myEncoder.encode(bitmapData);
 
 var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");
 
 var saveJPG:URLRequest = new URLRequest("save.php");
 saveJPG.requestHeaders.push(header);
 saveJPG.method = URLRequestMethod.POST;
 saveJPG.data = byteArray;
 
 var urlLoader:URLLoader = new URLLoader();
 urlLoader.addEventListener(Event.COMPLETE, sendComplete);
 urlLoader.load(saveJPG);
 
 function sendComplete(event:Event):void{
  warn.visible = true;
  addChild(warn);
  warn.addEventListener(MouseEvent.MOUSE_DOWN, warnDown);
  warn.buttonMode = true;
 }
 
}
 
function warnDown(e:MouseEvent):void{
 navigateToURL(new URLRequest("images/"), "_blank");
 warn.visible = false;
}
 
warn.visible = false;

------------------------------------
<?php
if(isset($GLOBALS["HTTP_RAW_POST_DATA"])){
 $jpg = $GLOBALS["HTTP_RAW_POST_DATA"];
 $img = $_GET["img"];
 $filename = "images/poza_". mktime(). ".jpg";
 file_put_contents($filename, $jpg);
} else{
 echo "Encoded JPEG information not received.";
}
?>

Friday, December 31, 2010

How to Remove Unncessary Space Between lines in Dreamweaver?

  1. Open the file
  2. Click CTRL + F
  3. Select "Current document" in "Find in" (You can also select the folder if you have multiple files)
  4. Search in "Source code"
  5. Tick "Use regular expression"
  6. Type [\r\n]{2,} (without quotes) in "Find"
  7. Type \n (without quotes) in "Replace"
  8. Press "Replace All"

Monday, December 20, 2010

fck editor upload solved

To assign the filebrowser plugin to an element inside of a dialog box, set the "filebrowser" property. For example in _source/plugins/image/dialogs/image.js there is:
{
 type : 'button',
 hidden : true,
 id : 'browse',
 filebrowser : 'Link:txtUrl',
 label : editor.lang.common.browseServer,
 style : 'float:right',
},

Adding "Quick Upload" support

Again, to see how we can handle file uploads in our dialog box, we'll use working example from CKEditor. In _source/plugins/image/dialogs/image.js there is a definition of the Upload tab:
{ id : 'Upload', hidden : true, filebrowser : 'uploadButton', label : editor.lang.image.upload, elements : [ { type : 'file', id : 'upload', label : editor.lang.image.btnUpload, style: 'height:40px', size : 38 }, { type : 'fileButton', id : 'uploadButton', filebrowser : 'info:txtUrl', label : editor.lang.image.btnUpload, 'for' : [ 'Upload', 'upload' ] } ] },