|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-05-30 04:33 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 01:00:02 2025 UTC |
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();