Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image 如何使用Gd库在codeigniter中显示动态按钮?_Image_Codeigniter_Gdlib - Fatal编程技术网

Image 如何使用Gd库在codeigniter中显示动态按钮?

Image 如何使用Gd库在codeigniter中显示动态按钮?,image,codeigniter,gdlib,Image,Codeigniter,Gdlib,我用动态颜色、字体、按钮大小创建表单。 当我提交表单时,按钮图像以整页显示,我需要显示在第一页本身 我的控制器代码: public function creatorbuton(){ $button_size = $this->input->POST('button_size'); $font_style = $this->input->POST('font_style'); $color_schme = $this->input->PO

我用动态颜色、字体、按钮大小创建表单。 当我提交表单时,按钮图像以整页显示,我需要显示在第一页本身

我的控制器代码:

public function creatorbuton(){
    $button_size = $this->input->POST('button_size');
    $font_style = $this->input->POST('font_style');
    $color_schme = $this->input->POST('color_schme');
    $textdisplay = $this->input->POST('textdisplay');
    header('content-type: image/png');

    //Create our basic image stream 
    //125px width, 125px height
    $image = imagecreate(120, 60);

    //Set the background color
    $blue = imagecolorallocate($image, 150, 50, 105);

    //Set up another color just to show how the first color declared is used as the background color when we use imagecreate() 
    //Notice how blue is applied to the background, *not* red.
    $red = imagecolorallocate($image, 150, 200, 10);

    //$font = myurl.'fonts/arial.ttf';
    //$text="Hello";
    //imagettftext($image, 20, 0, 11, 21, $red, $font, $text);
    //save the image as a png and output 
    $result_array['final_image'] = imagepng($image);

    //Clear up memory used
    imagedestroy($image);
    $this->load->view('buttonconfig/buttoncreator',$result_array);
如何在buttoncreator视图页面中显示按钮。当我使用取消注释这行时

imagettftext($image, 20, 0, 11, 21, $red, $font, $text);

我得到了这一行“图像我的URL无法显示,因为它包含错误”。

我得到了输出:我的代码是

public function creatorparam(){ 
    $bg_color="FF8640";
    $text_color="C7FFE3";
    $button_width =120;
    $button_height =90; 

    $r_bg = hexdec("0x".substr($bg_color,0,2));
    $g_bg = hexdec("0x".substr($bg_color,2,2));
    $b_bg = hexdec("0x".substr($bg_color,4,2));

    $r_bgt = hexdec("0x".substr($text_color,0,2));
    $g_bgt = hexdec("0x".substr($text_color,2,2));
    $b_bgt = hexdec("0x".substr($text_color,4,2));
    header('content-type: image/png');  
    $image = imagecreate($button_width, $button_height); 
    $blue = imagecolorallocate($image, $r_bg, $g_bg, $b_bg); 
    $red = imagecolorallocate($image, $r_bgt, $g_bgt, $b_bgt);  
    imagestring($image,18,0,0,$textdisplay,$red); 
    imagepng($image);
    imagedestroy($image); 
}

请在以后对代码的格式设置更加小心。如果您的代码易于阅读和理解,您就更有可能得到积极的响应