Using a GtkPreview under windows

From: Date: Sun, 04 Jul 2004 12:01:38 +0000
Subject: Using a GtkPreview under windows
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-4697@lists.php.net to get a copy of this message
Is it possible to use a GtkPreview (or, for that matter, any other widget) to display images on Windows? It seems like using GtkPixmap is out because windows doesn't have libxpm, so I came up with the following code to (theoretically) get the image into a GtkPreview ($imgwid is the preview widget, $res['body'] is the image data): if ($img = imagecreatefromstring($res['body'])) { // Now comes the stuff that's (mostly) a black art .... $width = imagesx($img); $height = imagesy($img); // For each row, create a string representing the rgb data from // each pixel $img_gdkwin = $imgwid->window; $tmp_gc = $img_gdkwin->new_gc(); for ($i = 0; $i < $height; $i++)
     {
       $rowdata = '';
       for ($j = 0; $j < $width; $j++)
         {
           $pixel = imagecolorat($img, $i, $j);
           $r = ($pixel & 0xFF0000) >> 16;
           $g = ($pixel & 0x00FF00) >> 8;
           $b = ($pixel & 0x0000FF);
           $rowdata .= pack("CCC", $r, $g, $b);
         }
       $imgwid->draw_row($rowdata, 0, $i, $width);
     }
} As far as I can tell, the first argument to draw_row() is supposed to be a string with every three bytes (for a color image) representing the R, G, and B for each pixel -- that's what the pack() call is trying to do. The only result of the above, though, is the message "draw_row() expects argument 1 to be string without null bytes, string given .....", and nothing appears in the preview window. Placing a 'str_replace("\000", "\001", $rowdata);' before the draw_row() call dosen't help, either. Searching the archives for that error message brought back only a couple of short threads that seemed to amount to "we're not too sure what to make of it, either" -- one was from this past March, and the other was from 2001. Any insights would be greatly appreciated. Thanks, Bryan

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