[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mapbender-dev
Subject:    [Mapbender-dev] weldMaps2PNG,
From:       jansen.marc () gmx ! de (Marc Jansen)
Date:       2007-01-11 9:11:20
Message-ID: 45A6381E.6020800 () gmx ! de
[Download RAW message or body]

Hey List,

As there seem to be no real issues with this, I suggest somebody with 
SVN-writting access might add these lines (see below a copied message).

Furthermore I'd like to suggest to use PHPs function imagedestroy (e.g. 
http://de2.php.net/imagedestroy), to clean up memory after image 
creation. I know that it's all done by PHP itself after script execution 
stopped, but I think we shouldn't be to messy and free most of the 
memory we occupated by ourselves ;-)

This would mean changing this code:

// old
imagecopy($image, $img, 0, 0, 0, 0, $width, $height);

To:
// new
imagecopy($image, $img, 0, 0, 0, 0, $width, $height);
@imagedestroy($img);


And the change of this line:
// old
imagepng($image,$filename);

To:
// old
imagepng($image,$filename);
imagedestroy($image);

Any more opinions?


-- Marc




Marc Jansen schrieb:
> Hi list,
>
> today I encountered some problems with transparency in the class 
> weldMaps2PNG.
>
> My problem was that I was forced to run the image-creation-class 
> within the printing module several times for one PDF. I added some 
> welded maps to the PDF and afterwards I had to add some more welded 
> maps. With the default settings in this class the module creates a 
> white image of given size and  adds  the single images (some might be 
> transparent) of the request URLs to this image.
>
> Without changes, it was impossible to simply create the second bunch 
> of maps and to just add them to the PDF, as the background of the 
> images is white and not transparent.
>
> I fixed this issue by replacing some of the lines in the class 
> weldMaps2PNG (in the constructor-function):
>
> old code:
> ------------------------------------------------------------
> $image = imagecreatetruecolor($width, $height);
> $white = ImageColorAllocate($image,255,255,255);
> ImageFilledRectangle($image,0,0,$width,$height,$white);
> ------------------------------------------------------------
>
> new code:
> ------------------------------------------------------------
> // do not use imagecreatetruecolor,
> // as the currently used PDF-creation-class
> // has some problems with this 24-bit PNGs
> $image = imagecreate($width, $height );
> // allocate a color as usual
> $white = imagecolorallocate($image,255,255,255);
> // set this color to transparent
> // no need to draw a rectangle in my case
> $white = imagecolortransparent($image, $white);
> ------------------------------------------------------------
>
> As for programming semantics and self-explaining code one might 
> consider to rename the variable $white to $transparent... ;-)
>
> Are there any opinions about this issue?
>
> -- Marc
>
>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic