Jump to:

3372 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Bug in sapphire/filesystem/GD.php

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 820 Views
  • hu
    Avatar
    Community Member
    21 Posts

    Bug in sapphire/filesystem/GD.php Link to this post

    OUT OF RANGE ERROR

       function greyscale($rv=38, $gv=36, $bv=26) {
          $width = $this->width;
          $height = $this->height;
          $newGD = imagecreatetruecolor($this->width, $this->height);
          
          $rt = $rv + $bv + $gv;
          $rr = ($rv == 0) ? 0 : 1/($rt/$rv);
          $br = ($bv == 0) ? 0 : 1/($rt/$bv);
          $gr = ($gv == 0) ? 0 : 1/($rt/$gv);
          for($dy = 0; $dy <= $height; $dy++) {
             for($dx = 0; $dx <= $width; $dx++) {

          for($dy = 0; $dy < $height; $dy++) {
             for($dx = 0; $dx < $width; $dx++) {

                $pxrgb = imagecolorat($this->gd, $dx, $dy);
                $heightgb = ImageColorsforIndex($this->gd, $pxrgb);
                $newcol = ($rr*$heightgb['red']) + ($br*$heightgb['blue']) + ($gr*$heightgb['green']);
                $setcol = ImageColorAllocate($newGD, $newcol, $newcol, $newcol);
                imagesetpixel($newGD, $dx, $dy, $setcol);
             }
          }
          
          // imagecopyresampled($newGD, $this->gd, 0,0, $srcX, $srcY, $width, $height, $srcWidth, $srcHeight);
          
          $output = new GD();
          $output->setGD($newGD);
          if($this->quality) $output->setQuality($this->quality);
          return $output;
       }

    820 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.