[cairo] Problem with PHP extension writing (under use of Cairo)
"tschobber tschöbbi"
tschobber at gmx.at
Thu Dec 25 01:34:47 PST 2008
Hi,
I'm having trouble with PHP extension writing (with C++ under Linux) when using Cairo functions: I use this link as a tutorial for extension writing http://devzone.zend.com/node/view/id/1021. the problem is that all is working fine when i call functions with no cairo code in it, but when I call the function below php just aks me if I want to save the .php file on disk. Maybe it is because i just copied the headerfiles into the source folder under the php sourcetree because before the source file didn't compile because of missing the header files of cairo.
Source a PHP function using cairo:
PHP_FUNCTION(paint_with_cairo)
{
long shape = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &shape) == FAILURE) {
RETURN_NULL();
}
cairo_t *cr;
cairo_surface_t *surface;
int x, y, count_rows,i;
int width, height = 100;
//surface = (cairo_surface_t *) cairo_svg_surface_create("Cairo_example.png", 1000.0, 1000.0);
surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,2000,2000);
//surface = (cairo_surface_t *) ("Cairo_example.svg", 2000.0, 2000.0);
cr = cairo_create(surface);
y = 1;
count_rows = 0;
for (i = 0; i < (numShapes); i++){
if(count_rows > 10){
y++;
x = 0;
count_rows = 0;
}
if(shape == 0){
cairo_rectangle(cr, x * 90, y * 70, 80, 55);
}else if(shape == 1){
cairo_set_source_rgb(cr, 0.4, 0.5, 0.5);
cairo_arc(cr, x*120+60, y*120+60, 60, 0, 2*M_PI);
cairo_stroke_preserve(cr);
cairo_set_source_rgb(cr, 0.5, 0.2, 0.1);
cairo_fill(cr);
}else{
cairo_move_to(cr, 80*x, 80*y);
cairo_set_source_rgb(cr, 0.4, 0.5, 0.5);
cairo_line_to(cr, 80*x, (80*y)+75);
cairo_line_to(cr, (80*x)+75, (80*y));
cairo_line_to(cr, 80*x, 80*y);
cairo_close_path(cr);
}
x++;
count_rows++;
}
cairo_fill(cr);
//cairo_set_source_rgb(cr, 0, 0, 0);
cairo_surface_write_to_png(surface,"/opt/lampp/lampp/htdocs/bla/c_example.png");
cairo_destroy(cr);
cairo_surface_destroy(surface);
}
i hope you can help me solving the problem.
regards,
martin
--
Sensationsangebot verlängert: GMX FreeDSL - Telefonanschluss + DSL
für nur 16,37 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K1308T4569a
More information about the cairo
mailing list