|
Posted by Jochem Maas on 10/07/77 11:33
imagecreatetruecolor() is probably what your after:
http://php.net/imagecreatetruecolor
Albert wrote:
> I have two images which I want to overlay on each other.
>
> Image1 is a satellite image.
> Image2 is contains the statistical data we collected. It has a transparent
> background and should be overlaid on top of the satellite image.
>
> Both are in PNG format.
>
> My current code:
>
> <?
> $dataImage = imagecreate(1000, 1000);
> $dIBack = imagecolorallocate($dataImage, 199, 199, 199);
> imagecolortransparent($dataImage, $dIBack);
> $darkGreen = imagecolorallocate($tileImage, 2, 123, 48 );
> $grey = imagecolorallocate($tileImage, 118, 131, 120);
> $fuchsia = imagecolorallocate($tileImage, 255, 0, 255);
> $aqua = imagecolorallocate($tileImage, 113, 168, 194);
> $brown = imagecolorallocate($tileImage, 177, 170, 107);
> $offwhite = imagecolorallocate($tileImage, 187, 210, 193);
> $black = imagecolorallocate($tileImage, 0, 0, 0 );
> $blue = imagecolorallocate($tileImage, 0, 0, 255);
> $red = imagecolorallocate($tileImage, 255, 0, 0 );
> $yellow = imagecolorallocate($tileImage, 255, 255, 0 );
>
> /* Code to draw data on image comes here */
>
> $satImage = imagecreatefrompng(‘sat_image.png’);
>
> $mergedImage = imagecreate(1000, 1000);
> imagealphablending($mergedImage, true);
> imagecopy($mergedImage, $satImage, 0, 0, 0, 0, 1000, 1000);
> imagecopy($mergedImage, $dataImage, 0, 0, 0, 0, 1000, 1000);
>
> imagepng($mergedImage, ‘merged_image.png’);
>
> imagedestroy($mergedImage);
> imagedestroy($satImage);
> imagedestroy($dataImage);
> ?>
>
> Notes:
> 1. When using imagecreatetruecolor the images turn black
> 2. When using imagealphablending = true or imagealphablending = false
> with imagecopy the result is the same. The top image is shown but it is
> almost transparent. Some images are also discoloured.
> 3. When using imagecopymerge to copy with a pct value of 99, and commenting
> out the imagealphablending line the top image does not appear at all
> 4. When using imagecopymerge to copy with a pct value of 99, and
> imagealphablending=true, it has the same result as 2. above.
> 5. When using imagecopymerge to copy with a pct value of 50, and
> Imagealphablending=true, it has the same result as 2. above.
>
> What is the effect of the pct value of imagecopymerge?
>
> Should I be using different values for the pct value of imagecopymerge or is
> there an alternative method which will do what I want to be done?
>
> It seems to me that the palette used in the top image is not merged with the
> palette used in the satellite image.
>
> Albert
>
Navigation:
[Reply to this message]
|