Integration of libcairo in pvbrowser
Content Forward

libcairo

Integration with pvbrowser

libcairo https://cairographics.org is a powerful low level graphics library that supports many output formats and runs on all common platforms. Here we are particularly interested in raster graphics in PNG format and vector graphics in SVG format as output of libcairo and their integration into pvbrowser and normal webbrowser.

In https://en.wikipedia.org/wiki/Cairo_(graphics) you can find a small programming example in ANSI C for libcairo.

snap1.png
Programming example for libcairo

The following sources can be found in the directory "pvbaddon/template/cairo" of the pvbaddon.tar.gz add-on package for pvbrowser.

snap2.png
Programming example integrated in pvbrowser

The integration of libcairo is achieved by the class pvCairo. This offers the possibility to select with "setSurfaceToUse()" whether PNG or SVG output should be generated and whether it should be for a pvbrowser QDraw widget, a file or a response to an HTTP GET request.

pvcairo.png
Integration with the help of the class pvCairo

With "beginDraw()" you get a cairo_t context, which you need for the calls of the painting functions of libcairo. With "endDraw()" the painting operations are terminated and dynamically assigned resources are released.

If the output to a file is made PARAM *p=NULL; otherwise PARAM *p specifies the network connection, via which the output is sent to a pvbrowser widget with the ID "int id" or to a connected web browser in response to an HTTP GET request.

The method "sendFileToQDraw()" is a helper function to send PNG or SVG files to a QDraw widget in pvbrowser. If the time rlTime *ftime; is used, the method only sends if the modification time of the file has not changed.


Content Forward