public function transform(CGImageBase $src) { $width = $src['width']; $height = $src['height']; $radius = $this->_radius; $type = $src['type']; $color = null; $r = $g = $b = 255; if ($src->supports_transparency() && !$this->_color) { $this->_color = 'transparent'; } if ($this->_color == 'transparent') { $type = 'image/png'; } $_dest = new CGImageBase(array($type, $width, $height)); imagecopy($_dest['rsrc'], $src['rsrc'], 0, 0, 0, 0, $width, $height); if ($this->_color) { if ($this->_color == 'transparent') { // get the dest imagages transparent color. $color = $_dest['transparent']; if (!$color) { list($r, $g, $b) = cgsi_utils::find_unused_color($_dest); } } else { // use the specified rgb. list($r, $g, $b) = cgsi_utils::color_to_rgb($this->_color); } } if (!$color) { if ($this->_color == 'transparent') { $color = imagecolorallocatealpha($_dest['rsrc'], $r, $g, $b, 127); } else { $color = imagecolorallocate($_dest['rsrc'], $r, $g, $b); } } if ($this->_color == 'transparent') { $_dest['transparent'] = $color; imagecolortransparent($_dest['rsrc'], $color); imagealphablending($_dest['rsrc'], FALSE); } // round the corners. imagearc($_dest['rsrc'], $radius - 1, $radius - 1, $radius * 2, $radius * 2, 180, 270, $color); imagefilltoborder($_dest['rsrc'], 0, 0, $color, $color); imagearc($_dest['rsrc'], $width - $radius, $radius - 1, $radius * 2, $radius * 2, 270, 0, $color); imagefilltoborder($_dest['rsrc'], $width - 1, 0, $color, $color); imagearc($_dest['rsrc'], $radius - 1, $height - $radius, $radius * 2, $radius * 2, 90, 180, $color); imagefilltoborder($_dest['rsrc'], 0, $height - 1, $color, $color); imagearc($_dest['rsrc'], $width - $radius, $height - $radius, $radius * 2, $radius * 2, 0, 90, $color); imagefilltoborder($_dest['rsrc'], $width - 1, $height - 1, $color, $color); return $_dest; }