| View previous topic :: View next topic |
| Author |
Message |
leon_pegg
Joined: 12 Jun 2006 Posts: 113 Location: hemel / UK
|
Posted: Thu Jun 29, 2006 7:50 pm Post subject: php-gtk2 with gd |
|
|
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
|
Posted: Thu Jun 29, 2006 8:06 pm Post subject: |
|
|
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
|
Posted: Thu Jun 29, 2006 8:52 pm Post subject: |
|
|
| 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
|
Posted: Thu Jun 29, 2006 9:06 pm Post subject: |
|
|
| 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
|
Posted: Fri Jun 30, 2006 1:38 am Post subject: |
|
|
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
|
Posted: Fri Aug 17, 2007 4:26 am Post subject: Re: php-gtk2 with gd |
|
|
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 |
|
 |
|