Solved

Create Image in Flash from BitMapdata

Posted on 2009-04-08
2
323 Views
Last Modified: 2013-11-11
Hi,

I am using the bitmapdata class to create an image from a webcam.

I am then trying to save out this image using PHP, but the image colouring is all wrong.

Does anyone know if this is a flash or php problem and how to resolve?

Thanks
PHP code:
 

//If GD library is not installed, say sorry

	if(!function_exists("imagecreate")) die("Sorry, you need GD library to run this example");

	//Capture Post data

	$data = explode(",", $_POST['img']);

	$width = $_POST['width'];

	$height = $_POST['height'];

	//Allocate image

	$image=(function_exists("imagecreatetruecolor"))?imagecreatetruecolor( $width ,$height ):imagecreate( $width ,$height );

	//imagefill($image, 0, 0, 0xFFFFFF);

	//Copy pixels

	$i = 0;

	for($x=0; $x<=$width; $x++){

		for($y=0; $y<=$height; $y++){

			$r = hexdec("0x".substr( $data[$i] , 2 , 2 ));

			$g = hexdec("0x".substr( $data[$i] , 4 , 2 ));

			$b = hexdec("0x".substr( $data[$i++] , 6 , 2 ));

			$color = imagecolorallocate($image, $r, $g, $b);

			imagesetpixel ($image,$x,$y,$color);

		}

	}

	//Output image and clean

	header( "Content-type: image/jpeg" );

	ImageJPEG( $image );

	imagedestroy( $image );

Open in new window

0
Comment
Question by:coolispaul
2 Comments
 
LVL 6

Expert Comment

by:MatthewP
ID: 24109085
I wouldn't say it's a flash problem, it'll be something with the code. Can I ask what this does or is meant to do exactly? Are you trying to copy an image pixel by pixel to another image?

I just tried running it locally with one image as the input (on the command line) and it threw up an enormous number of notices and error messages.
0
 

Accepted Solution

by:
coolispaul earned 0 total points
ID: 25366257
used as3 in the end and sent on http rather than pixel by pixel
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now