Everyone:
I'm having a problem with a layering script I'm using. I have a project where we overlay several transparent PNG's over top of each other. All works well. But when I try to add certain layers that have text on it, it grays out the layers below it. If I load a similar layer that is transparent, but doesn't have any text on it, it stays transparent.
Any ideas? Me and another developer have been scratching our heads.
TIA!
<?php
/**
* @file all_layer_merge.php
* @brief Creates a single image with all layers for each WFO.
**/
// Increase maximum runtime and memory
set_time_limit(15);
ini_set("memory_limit", "32M");
// include our config code
require("config.php");
// validate the list of data passed
if (!isset($_GET["layers"]) || !ereg("^[0-9]{1,2}(,[0-9]{1,2}){0,}$", $_GET["layers"])) {
// stop here
print "A proper layer list was not passed.";
exit();
}
// Set directories
$hsa_image_dir = $baseDir . "images/ahps2/ahps2_hsa_maps";
// set our image width and height attributes
$width = 600;
$height = 550;
// create an array from our passed list of layers
$arrDisplay = explode(",", $_GET["layers"]);
// create our true color image
$image_p = imagecreatetruecolor($width, $height);
// create our image identifiers
$hsa_topo_img = imagecreatefromjpeg("$hsa_image_dir/" . $myWFO . "/" . $myWFO . "_topo_light.jpg");
ImageCopyResized($image_p, $hsa_topo_img, 0, 0, 0, 0, $width, $height, $width, $height);
// start adding our layers that we need to display
if (in_array(0, $arrDisplay)) {
$hsa_topo_img2 = imagecreatefromjpeg("$hsa_image_dir/" . $myWFO . "/" . $myWFO . "_topo.jpg");
ImageCopyResized($image_p, $hsa_topo_img2, 0, 0, 0, 0, $width, $height, $width, $height);
}
if (in_array(1, $arrDisplay)) {
$hsa_counties_img = @imagecreatefromgif("$hsa_image_dir/" . $myWFO . "/" . $myWFO . "_counties.gif");
ImageCopyResized($image_p, $hsa_counties_img, 0, 0, 0, 0, $width, $height, $width, $height);
}
if (in_array(8, $arrDisplay)) {
$hsa_states_img = @imagecreatefromgif("$hsa_image_dir/" . $myWFO . "/" . $myWFO . "_states.gif");
ImageCopyResized($image_p, $hsa_states_img, 0, 0, 0, 0, $width, $height, $width, $height);
}
if (in_array(2, $arrDisplay)) {
$hsa_rivers_img = @imagecreatefromgif("$hsa_image_dir/" . $myWFO . "/" . $myWFO . "_rivers.gif");
ImageCopyResized($image_p, $hsa_rivers_img, 0, 0, 0, 0, $width, $height, $width, $height);
}
if (in_array(3, $arrDisplay)) {
$hsa_highways_img = @imagecreatefromgif("$hsa_image_dir/" . $myWFO . "/" . $myWFO . "_highways.gif");
ImageCopyResized($image_p, $hsa_highways_img, 0, 0, 0, 0, $width, $height, $width, $height);
}
if (in_array(4, $arrDisplay)) {
$hsa_cities_img = @imagecreatefromgif("$hsa_image_dir/" . $myWFO . "/" . $myWFO . "_cities.gif");
ImageCopyResized($image_p, $hsa_cities_img, 0, 0, 0, 0, $width, $height, $width, $height);
}
if (in_array(6, $arrDisplay)) {
$hsa_names_img = @imagecreatefrompng("$hsa_image_dir/" . $myWFO . "/ahps_gage_layer_" . $myWFO . "_name_all.png");
ImageCopyResized($image_p, $hsa_names_img, 0, 0, 0, 0, $width, $height, $width, $height); // this fails and displays a gray background
}
if (in_array(7, $arrDisplay)) {
$hsa_gauges_img = @imagecreatefrompng("$hsa_image_dir/" . $myWFO . "/ahps_gage_layer_" . $myWFO . ".png");
ImageCopyResized($image_p, $hsa_gauges_img, 0, 0, 0, 0, $width, $height, $width, $height);
}
// load our legend layer last
$hsa_legend_img = @imagecreatefrompng("$hsa_image_dir/" . $myWFO . "/ahps_gage_layer_" . $myWFO . "_legend.png");
ImageCopyResized($image_p, $hsa_legend_img, 0, 0, 0, 0, $width, $height, $width, $height);
// print our MIME-type
header("Content-type: image/jpeg");
// display the image
imagejpeg($image_p);
// destroy the image from memory
imagedestroy($image_p);
?>