#37636 [Opn->Csd]: GdkPixbuf::new_from_gd transfers red colors only
| From: | andrei@php.net | Date: | Sat, 09 Sep 2006 20:23:16 +0000 |
| Subject: | #37636 [Opn->Csd]: GdkPixbuf::new_from_gd transfers red colors only | ||
| References: | 1 | Groups: | php.gtk.dev |
| Request: | Send a blank email to php-gtk-dev+get-3404@lists.php.net to get a copy of this message | ||
ID: 37636
Updated by: andrei@php.net
Reported By: cweiske@php.net
-Status: Open
+Status: Closed
Bug Type: PHP-GTK related
Operating System: Linux
PHP Version: 5.1.4
New Comment:
I committed what I think is the correct fix to gdk.overrides. Please
test and report back.
Previous Comments:
------------------------------------------------------------------------
[2006-06-09 20:28:05] cweiske@php.net
Since it works on Andrei's laptop (a Macbook with G4 processor), but
not on my pc nor on scott's pc, I assume it's an endian problem. The
bits are in the wrong order for PCs.
------------------------------------------------------------------------
[2006-06-09 18:26:07] cweiske@php.net
Even your example shows the wrong colors.
See:
http://xml.cweiske.de/2006-06-09%20new_from_gd%20wrong%20colors.png
Try to set the colors to:
$bg = imagecolorallocate($image, 0, 255, 0);
$blue = imagecolorallocate($image, 0, 0, 255);
which have no red in them. The image will be totally transparent
------------------------------------------------------------------------
[2006-06-03 18:55:55] andrei@php.net
Can you provide a shorter example without using Image_Graph? My tests
show that everything transfers fine.
<?php
$w = new GtkWindow();
$w->connect_simple('destroy', array('gtk', 'main_quit'));
$values = array(
40, 50, // Point 1 (x, y)
20, 240, // Point 2 (x, y)
60, 60, // Point 3 (x, y)
240, 20, // Point 4 (x, y)
50, 40, // Point 5 (x, y)
10, 10 // Point 6 (x, y)
);
// create image
$image = imagecreatetruecolor(250, 250);
// some colors
$bg = imagecolorallocate($image, 200, 200, 200);
imagefill($image, 0, 0, $bg);
imagecolortransparent($image, $bg);
$blue = imagecolorallocate($image, 150, 90, 255);
// draw a polygon
imagefilledpolygon($image, $values, 6, $blue);
$pixbuf = GdkPixbuf::new_from_gd($image);
$b = new GtkButton();
$pixmap = GtkImage::new_from_pixbuf($pixbuf);
$b->add($pixmap);
$w->add($b);
$w->show_all();
gtk::main();
------------------------------------------------------------------------
[2006-05-30 04:33:27] cweiske@php.net
Description:
------------
GdkPixbuf::new_from_gd() seems to transfer the red parts of the picture
to the pixbuf. Even when there is a black line, it appears light grey on
the pixbuf.
Reproduce code:
---------------
<?php
//image_graph multiple plots usage example
error_reporting(E_ALL);
include 'Image/Graph.php';
// create the graph
$Graph =& Image_Graph::factory('graph', array(600, 400));
// add a TrueType font
$Font =& $Graph->addNew('font', 'Verdana');
// set the font size to 11 pixels
$Font->setSize(8);
$Graph->setFont($Font);
// create the plotarea
$Graph->add(
Image_Graph::vertical(
Image_Graph::vertical(
$Title = Image_Graph::factory('title', array('Multiple
Plots', 11)),
$SubTitle = Image_Graph::factory('title', array('This is a
demonstration of title alignment', 7)),
90
),
$Plotarea = Image_Graph::factory('plotarea'),
8
)
);
$Title->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
$SubTitle->setAlignment(IMAGE_GRAPH_ALIGN_LEFT);
$Grid =& $Plotarea->addNew('bar_grid', IMAGE_GRAPH_AXIS_Y);
$Grid->setFillStyle(Image_Graph::factory('gradient',
array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'lightgrey')));
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Smoothed_Area',
Image_Graph::factory('random', array(10, 20, 100, true)));
$Plot->setFillColor('red@0.2');
$Plot =& $Plotarea->addNew('line', Image_Graph::factory('random',
array(10, 20, 100, true)));
$Plot->setLineColor('blue@0.2');
$CircleMarker =& Image_Graph::factory('Image_Graph_Marker_Circle');
$Plot->setMarker($CircleMarker);
$CircleMarker->setFillColor('white@0.4');
$Plot =& $Plotarea->addNew('bar', Image_Graph::factory('random',
array(10, 2, 40, true)));
$Plot->setFillColor('green@0.2');
$Marker =& Image_Graph::factory('Image_Graph_Marker_Value',
IMAGE_GRAPH_VALUE_Y);
$Plot->setMarker($Marker);
$Marker->setFillColor('white');
$Marker->setBorderColor('black');
$AxisY = $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$AxisY->showArrow();
$Array = array(
"Jan-Feb\n2004",
"Mar-Apr\n2004",
"May-Jun\n2004",
"Jul-Aug\n2004",
"Sep-Oct\n2004",
"Nov-Dev\n2004",
"Jan-Feb\n2005",
"Mar-Apr\n2005",
"May-Jun\n2005",
"Jul-Aug\n2005"
);
$AxisX = $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
$AxisX->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Array',
array($Array)));
//that is a critical line. Setting the output to "none" is important
$Graph->done(array('output' => 'none'));
$canvas = $Graph->_getCanvas();
$gd = $canvas->_canvas;
$pixbuf = GdkPixbuf::new_from_gd($gd);
$wnd = new GtkWindow();
$wnd->connect_simple('destroy', array('Gtk', 'main_quit'));
$wnd->add(GtkImage::new_from_pixbuf($pixbuf));
$wnd->show_all();
Gtk::main();
?>
Expected result:
----------------
http://xml.cweiske.de/2006-05-30%20multiple_slots_original.png
Actual result:
--------------
http://xml.cweiske.de/2006-05-30%20multiple_slots_gtk.png
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37636&edit=1