SlightPHP\SimpleCaptcha::ImageAllocate PHP Method

ImageAllocate() protected method

Creates the image resources
protected ImageAllocate ( )
    protected function ImageAllocate()
    {
        // Cleanup
        if (!empty($this->im)) {
            imagedestroy($this->im);
        }
        $this->im = imagecreatetruecolor($this->width * $this->scale, $this->height * $this->scale);
        // Background color
        $this->GdBgColor = imagecolorallocatealpha($this->im, $this->backgroundColor[0], $this->backgroundColor[1], $this->backgroundColor[2], 0);
        imagefill($this->im, 0, 0, $this->GdBgColor);
        //  imagefilledrectangle($this->im, 0, 0, $this->width*$this->scale, $this->height*$this->scale, $this->GdBgColor);
        // Foreground color
        $color = $this->colors[mt_rand(0, sizeof($this->colors) - 1)];
        $this->GdFgColor = imagecolorallocate($this->im, $color[0], $color[1], $color[2]);
        // Shadow color
        if (!empty($this->shadowColor)) {
            $this->GdShadowColor = imagecolorallocate($this->im, $this->shadowColor[0], $this->shadowColor[1], $this->shadowColor[2]);
        }
    }