Re: Re: [imagick] converting to variable instead of file

From: Date: Sun, 07 Sep 2003 15:51:54 +0000
Subject: Re: Re: [imagick] converting to variable instead of file
References: 1 2  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-3825@lists.php.net to get a copy of this message
Can't you just attach a screenshot? (I for one don't have imagemagick handy right now). ----- Original Message ----- From: "Decapode Azur" <blue_prawn@tuxfamily.org> To: <magick-users@imagemagick.org> Cc: <php-general@lists.php.net>; <php-gtk-general@lists.php.net> Sent: Sunday, September 07, 2003 2:45 PM Subject: [PHP-GTK] Re: [imagick] converting to variable instead of file > finaly I did it this way : (pasted at the end of the mail) > > But the problem is the result is very dirty, > considering the result with other way to do this. > > top-left is the image in XPM-format > top-right is the image in PNG-format > bottom-left is a classic php-gtk-script displaying an XPM image > bottom-right is the php-script below loading and displaying a PNG img > > Why is the result so bad ? > > ======================================= > <?php > if ( !extension_loaded( 'gtk' ) ) > strstr( PHP_OS, 'Linux' ) ? dl('php_gtk.so') : dl('php_gtk.dll'); > > $handle = imagick_readimage( 'images/img.1.png' ); > if ( imagick_iserror( $handle ) ) { > $reason = imagick_failedreason( $handle ); > $description = imagick_faileddescription( $handle ); > print "handle failed!\nReason: $reason\nDescription: > $description\n"; > exit; > } > imagick_convert( $handle, 'XPM' ); > if ( !( $image_data = imagick_image2blob( $handle ) ) ) { > $reason = imagick_failedreason( $handle ); > $description = imagick_faileddescription( $handle ); > print "imagick_image2blob() failed\nReason: $reason\nDescription: > $description\n"; > exit; > } > > $head = '!/\*\s*XPM\s*\*/\s*static\s*char\s*\*\[\]\s*=\s*{\s*/\*\s*columns > rows colors chars-per-pixel\s*\*/\s*!'; > $image_data = preg_replace( $head, '', $image_data ); > $image_data = preg_replace( '!/\*\s*pixels\s*\*/\s*!m', '', $image_data ); > $image_data = preg_replace( '!"\s*};\s*$!', '', $image_data ); > $image_data = preg_replace( '!(^"|",$)!m', '', $image_data ); > > $image_data = explode( "\n", $image_data ); > > $win = &new GtkWindow(); > $win->connect( 'destroy', create_function( '', 'Gtk::main_quit();' ) ); > $win->set_usize( 256, 256 ); > $win->realize(); > > $transp = &new GdkColor( 1, 0, 0 ); > list( $pixmap, $mask ) = Gdk::pixmap_create_from_xpm_d( $win->window, > $transp, $image_data ); > $image = &new GtkPixmap( $pixmap, $mask ); > > $box = &new GtkVbox(); > $box->add( $image ); > $win->add( $box ); > $win->show_all(); > > Gtk::main(); > > ?> > > -- > PHP-GTK General Mailing List (http://gtk.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.gtk.general (#3825) next »