imagecopymerge trouble
Posted: Wed Sep 05, 2007 10:17 am
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
thank you in advance
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");
?>