image - How to display dynamic button in codeigniter using Gd library? -
i created form dynamic color,font,size of button . when submit form, button image displaying in full page,i need display in first page itself.
my controller code :
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 background color $blue = imagecolorallocate($image, 150, 50, 105); //set color show how first color declared used background color when use imagecreate() //notice how blue applied 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 image png , output $result_array['final_image'] = imagepng($image); //clear memory used imagedestroy($image); $this->load->view('buttonconfig/buttoncreator',$result_array);
how dispaly button in buttoncreator view page. when used uncomment line
imagettftext($image, 20, 0, 11, 21, $red, $font, $text);
i got line " image url cannot displayed baecause contains errors" .
i got output : code
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); }
Comments
Post a Comment