Solved

Create Image in Flash from BitMapdata

Posted on 2009-04-08
2
328 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Difference between PHPClasse.php and SimplXLS.php 5 45
Change Wording in Wordpress Plugin 4 38
Php variable to be sent back 3 34
Insert PHP into HTML page. 7 51
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

732 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