roundcubemail/plugins/identicon/identicon_engine.php
private function generateGD()
    {
        $color   = $this->toRGB($this->color);
        $bgcolor = $this->toRGB($this->bgcolor);

        // create an image, setup colors
        $image   = imagecreate($this->width, $this->height);
        $color   = imagecolorallocate($image, $color[0], $color[1], $color[2]);
        $bgcolor = imagecolorallocate($image, $bgcolor[0], $bgcolor[1], $bgcolor[2]);

        imagefilledrectangle($image, 0, 0, $this->width, $this->height, $bgcolor);

        // draw the grid created in self::generate()
        foreach ($this->grid as $item) {
            if ($item['active']) {
                imagefilledrectangle($image, $item['x1'], $item['y1'], $item['x2'], $item['y2'], $color);
            }
        }

        // generate an image and save it to a variable
        ob_start();
        imagepng($image, null, 6, PNG_ALL_FILTERS);
        $this->binary = ob_get_contents();
        ob_end_clean();

        // cleanup
        imagedestroy($image);
    }
private function generateGD()
    {
        $color   = $this->toRGB($this->color);
        $bgcolor = $this->toRGB($this->bgcolor);

        // create an image, setup colors
        $image   = imagecreate($this->width, $this->height);
        $color   = imagecolorallocate($image, $color[0], $color[1], $color[2]);
        $bgcolor = imagecolorallocate($image, $bgcolor[0], $bgcolor[1], $bgcolor[2]);

        imagefilledrectangle($image, 0, 0, $this->width, $this->height, $bgcolor);

        // draw the grid created in self::generate()
        foreach ($this->grid as $item) {
            if ($item['active']) {
                imagefilledrectangle($image, $item['x1'], $item['y1'], $item['x2'], $item['y2'], $color);
            }
        }

        // generate an image and save it to a variable
        ob_start();
        imagepng($image, null, 6, PNG_ALL_FILTERS);
        $this->binary = ob_get_contents();
        ob_end_clean();

        // cleanup
        imagedestroy($image);
    }
private function generateGD ( ) { $ color = $ this -> toRGB ( $ this -> color ) ; $ bgcolor = $ this -> toRGB ( $ this -> bgcolor ) ; // create an image, setup colors $ image = imagecreate ( $ this -> width , $ this -> height ) ; $ color = imagecolorallocate ( $ image , $ color [ 0 ] , $ color [ 1 ] , $ color [ 2 ] ) ; $ bgcolor = imagecolorallocate ( $ image , $ bgcolor [ 0 ] , $ bgcolor [ 1 ] , $ bgcolor [ 2 ] ) ; imagefilledrectangle ( $ image , 0 , 0 , $ this -> width , $ this -> height , $ bgcolor ) ; // draw the grid created in self::generate() foreach ( $ this -> grid as $ item ) { if ( $ item [ 'active' ] ) { imagefilledrectangle ( $ image , $ item [ 'x1' ] , $ item [ 'y1' ] , $ item [ 'x2' ] , $ item [ 'y2' ] , $ color ) ; } } // generate an image and save it to a variable ob_start ( ) ; imagepng ( $ image , null , 6 , PNG_ALL_FILTERS ) ; $ this -> binary = ob_get_contents ( ) ; ob_end_clean ( ) ; // cleanup imagedestroy ( $ image ) ; }
GD-based icon generation worker
GD - based icon generation worker