summaryrefslogtreecommitdiff
path: root/rotord/src/graph.h
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-11-01 16:56:52 +0000
committerTim Redfern <tim@eclectronics.org>2013-11-01 16:56:52 +0000
commit2c74f2bf6cba53e17b5b36beacc895a121de3b4d (patch)
tree8ac67bb64835019f5d93c2a27f7c2153165c849c /rotord/src/graph.h
parente67e0a69e8f168646076d26e7317eaec4e02058a (diff)
listnode/json
Diffstat (limited to 'rotord/src/graph.h')
-rw-r--r--rotord/src/graph.h63
1 files changed, 27 insertions, 36 deletions
diff --git a/rotord/src/graph.h b/rotord/src/graph.h
index 50f3f87..ddf2471 100644
--- a/rotord/src/graph.h
+++ b/rotord/src/graph.h
@@ -97,42 +97,33 @@ namespace Rotor {
class Thumbnailer{
public:
bool make(const string &inputfilename,int w,int h,const string &outputfilename) {
- //Poco::StringTokenizer t1(inputfilename,".");
- //if (t1.count()>1) {
- // if (t1[t1.count()-1]=="svg"){
- // cerr<<"found an svg"<<endl;
- RsvgHandle * rsvg=rsvg_handle_new_from_file(inputfilename.c_str(),nullptr);
- if (rsvg) {
- RsvgDimensionData dims;
- rsvg_handle_get_dimensions(rsvg,&dims);
- cerr<<"Rotor: SVG loaded "<<inputfilename<<" , "<<dims.width<<"x"<<dims.height<<endl;
- cv::Mat cp=cv::Mat::zeros(h,w,CV_8UC4);
- cv::Mat co=cv::Mat(h,w,CV_8UC3);
- cairo_surface_t * cs = cairo_image_surface_create_for_data (cp.data,
- CAIRO_FORMAT_RGB24,
- w,
- h,
- w*4);
- cairo_t * cr = cairo_create (cs);
- cairo_translate(cr, w/2, h/2);
- cairo_scale(cr, ((float)w)/640.0f,((float)w)/640.0f);
- cairo_translate(cr, -w/2, -h/2);
- cairo_translate(cr, w/2-(dims.width/2), h/2-(dims.height/2));
- rsvg_handle_render_cairo(rsvg,cr);
- cv::cvtColor(cp,co,CV_RGBA2BGR,3);
- cv::imwrite(outputfilename.c_str(),co);
- cairo_destroy(cr);
- cairo_surface_destroy(cs);
- rsvg_handle_close(rsvg,nullptr);
- g_object_unref(rsvg);
- return true;
- }
- // else {
- // cerr<<"Rotor: SVG failed to load "<<inputfilename<<endl;
- // return false;
- // }
- // }
- //}
+ //first try svg
+ RsvgHandle * rsvg=rsvg_handle_new_from_file(inputfilename.c_str(),nullptr);
+ if (rsvg) {
+ RsvgDimensionData dims;
+ rsvg_handle_get_dimensions(rsvg,&dims);
+ cerr<<"Rotor: SVG loaded "<<inputfilename<<" , "<<dims.width<<"x"<<dims.height<<endl;
+ cv::Mat cp=cv::Mat::zeros(h,w,CV_8UC4);
+ cv::Mat co=cv::Mat(h,w,CV_8UC3);
+ cairo_surface_t * cs = cairo_image_surface_create_for_data (cp.data,
+ CAIRO_FORMAT_RGB24,
+ w,
+ h,
+ w*4);
+ cairo_t * cr = cairo_create (cs);
+ cairo_translate(cr, w/2, h/2);
+ cairo_scale(cr, ((float)w)/640.0f,((float)w)/640.0f);
+ cairo_translate(cr, -w/2, -h/2);
+ cairo_translate(cr, w/2-(dims.width/2), h/2-(dims.height/2));
+ rsvg_handle_render_cairo(rsvg,cr);
+ cv::cvtColor(cp,co,CV_RGBA2BGR,3);
+ cv::imwrite(outputfilename.c_str(),co);
+ cairo_destroy(cr);
+ cairo_surface_destroy(cs);
+ rsvg_handle_close(rsvg,nullptr);
+ //g_object_unref(rsvg);
+ return true;
+ }
//if not svg feed to FFMS2
if (player.open(inputfilename)){
if (player.fetch_frame(w,h,player.get_number_frames()/4)) {