Skip to content

Commit

Permalink
fix cs
Browse files Browse the repository at this point in the history
  • Loading branch information
avalanche123 committed Jul 8, 2011
1 parent cc18a18 commit c2d0dce
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions lib/Imagine/Gd/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,41 +512,39 @@ private function saveOrOutput($format, array $options, $filename = null, Color $
}

/*
* Very weight treatment, but obligate to transform each pixels
* Very heavy treatment, but obligate to transform each pixels
*/

if ( $format === 'gif'){
$output = $this->createImage($this->getSize(), 'save jpeg');
$size = $this->getSize();
$color = $background ? $background : new Color('ffffff');

if ($format === 'gif'){
$size = $this->getSize();
$output = $this->createImage($size, 'save jpeg');
$color = $background ? $background : new Color('ffffff');
$lightalpha = $strongalpha = false;
for($x=0; $x<$this->getSize()->getWidth(); $x++){
for($y=0; $y<$this->getSize()->getHeight(); $y++){

for ($x = 0; $x < $size->getWidth(); $x++) {
for ($y = 0; $y < $size->getHeight(); $y++) {
$rgb = imagecolorat($this->resource, $x, $y);
$colorAt = imagecolorsforindex($this->resource, $rgb);
//100 because resize with copyresampled dissolve colors,
//normaly 1 for gif to gif, but as before ending, the output format isn't known...
if($colorAt['alpha']>=100){
if ($colorAt['alpha'] >= 100) {
imagesetpixel($this->resource, $x, $y, $this->getColor($color));
$strongalpha = true;
}elseif($colorAt['alpha']>0){
} elseif ($colorAt['alpha'] > 0) {
$lightalpha = true;
}
}
}
if($lightalpha){ //set a background

if ($lightalpha) { //set a background
imagefill($output, 0, 0, $this->getColor($color));
imagealphablending($output, true);
imagecopy($output, $this->resource, 0, 0, 0, 0, $size->getWidth(), $size->getHeight());
imagealphablending($output, false);
$this->resource = $output;
}

if($strongalpha){ //set a transparency
imagecolortransparent( $this->resource, $this->getColor($color));
if ($strongalpha) { //set a transparency
imagecolortransparent($this->resource, $this->getColor($color));
}

}
Expand Down

0 comments on commit c2d0dce

Please sign in to comment.