gnope php gtk gui gnope.org  

php-gtk2 with gd

 
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners
View previous topic :: View next topic  
Author Message
leon_pegg



Joined: 12 Jun 2006
Posts: 113
Location: hemel / UK

PostPosted: Thu Jun 29, 2006 7:50 pm    Post subject: php-gtk2 with gd Reply with quote

i have put this code together but every time i run it i get this error:-
Fatal error: PHP-GTK was not compiled against PHP with bundled GD library in C:\PHP-Gtk2\0012.phpw on line 7

the code :-
Code:
<?php
$data = file_get_contents("http://www.google.com/intl/en/images/logo.gif");

$gd = imagecreatefromstring($data);


$pixbuf = GdkPixbuf::new_from_gd($gd);
 
//Display the pixbuf by using a GtkImage widget
$wnd = new GtkWindow();
$wnd->connect_simple('destroy', array('Gtk', 'main_quit'));
$wnd->add(GtkImage::new_from_pixbuf($pixbuf));
$wnd->show_all();
Gtk::main();
?>


any help much thanked

regards leon
Back to top
cweiske



Joined: 08 Dec 2005
Posts: 454
Location: Leipzig/Germany

PostPosted: Thu Jun 29, 2006 8:06 pm    Post subject: Reply with quote

The problem is, that PHP-GTK was not compiled against PHP with bundled GD library.

It means at the time when PHP-Gtk for windows has been compiled , the PHP libraries used for compiling didn't contain gd. You can't change that.

Btw, the new_from_gd code is very buggy currently and works only on PPC processors (not your x86) correctly. So you've gotta wait for a new version.
Back to top
leon_pegg



Joined: 12 Jun 2006
Posts: 113
Location: hemel / UK

PostPosted: Thu Jun 29, 2006 8:52 pm    Post subject: Reply with quote

ok thanks for the reply hope i will be able to do this soon as alot of the programs i will be writing rely on pulling data from the internet and using them. I have writen a GTKDownload class witch i will be putting online soon.
Back to top
cweiske



Joined: 08 Dec 2005
Posts: 454
Location: Leipzig/Germany

PostPosted: Thu Jun 29, 2006 9:06 pm    Post subject: Reply with quote

leon, you don't need gd to load pictures from the net. Just use copy them via copy() into a temporary file (tempnam()) and load the pixbuf from there.
Back to top
leon_pegg



Joined: 12 Jun 2006
Posts: 113
Location: hemel / UK

PostPosted: Fri Jun 30, 2006 1:38 am    Post subject: Reply with quote

Thanks for the segestion solved the problem.
now i nerly have every thing writen for my application.
thanks for the help

regards leon pegg
Back to top
martin



Joined: 14 Aug 2007
Posts: 1
Location: Czech Republic

PostPosted: Fri Aug 17, 2007 4:26 am    Post subject: Re: php-gtk2 with gd Reply with quote

Hi, if you want to load online image from net without temp file you can try the code below but only small images. This is only example.
Code:

function loadPixbuff(&$data){
  if(!$im=@imagecreatefromstring($data)) return null;
  $X=imagesx($im);
  $Y=imagesy($im);
  $pb = new GdkPixbuf(Gdk::COLORSPACE_RGB, false, 8, $X, $Y);
  for($wY=0; $wY<$Y; $wY++){
    for($wX=0; $wX<$X; $wX++){
      $rgb_a = imagecolorsforindex($im, imagecolorat($im, $wX, $wY));
      $pb->fill_area($wX, $wY, 1, 1,
               (($rgb_a['red'] << 24)
             + ($rgb_a['green'] << 16)
             + ($rgb_a['blue'] << 8) + $rgb_a['alpha'])
                ); // fill_area
    } // for
  } // for
  imagedestroy($im);
  return $pb;
} // fnc
Back to top
Display posts from previous:   
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Templates enhanced by DigiWiki. Hosting by Tradebit.