Page 1 of 1

imagecopymerge trouble

Posted: Wed Sep 05, 2007 10:17 am
by bebensiganteng
i've just build an application in flash. what the application does basically allowed people to download an image from the flash application.

i use php to catch the pixel data from the flash and then use imagecopymerge to merge the image with another background image ( which contain address, copyright,etc )

but what happen is the result image its a bit transparent , the color are not sharp

do you guys know what going wrong here? below is the code
please help guys

Code: Select all

<?php

$SAVEPATH = "downloads/";

$imgBackground = imagecreatefromjpeg( 'template.jpg' ); 

//Catch the post data from flash

$width 		= (int)$_POST['width'];
$height	 	= (int)$_POST['height'];
$uniqueId 	= $_POST['uniqueId'];

$img = imagecreatetruecolor( $width, $height );

$imageBank = $SAVEPATH . $uniqueId ;

$rows = 0;
$cols = 0;

for($rows = 0; $rows < $height; $rows++)
{
	$colRow = explode(",", $_POST['px' . $rows]);
	
	for($cols = 0; $cols < $width; $cols++)
	{
		$value = $colRow[$cols];
		
		if($value != "")
		{
			$hex = $value;
			
			while(strlen($hex) < 6)
			{
				$hex = "0" . $hex;
			}
			
			$r = hexdec(substr($hex, 0, 2));
			$g = hexdec(substr($hex, 2, 2));
			$b = hexdec(substr($hex, 4, 2));
			
			$colorValue = imagecolorallocate($img, $r, $g, $b);
			
			imagesetpixel($img, $cols, $rows, $colorValue);
		}
	}
} 

imagecopymerge($imgBackground,$img,100,100,0,0,$width,$height,75);

imagejpeg($imgBackground, $imageBank . "_large.jpg");


?>
thank you in advance

Posted: Thu Sep 06, 2007 12:47 am
by bebensiganteng
guys any ideas? please

Posted: Thu Sep 06, 2007 2:11 am
by s.dot

Code: Select all

imagecopymerge($imgBackground,$img,100,100,0,0,$width,$height,75);
Just a guess here, but maybe if you change the 75 to 100.