summaryrefslogtreecommitdiff
path: root/rotord/src/graph.h
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/src/graph.h')
-rw-r--r--rotord/src/graph.h38
1 files changed, 37 insertions, 1 deletions
diff --git a/rotord/src/graph.h b/rotord/src/graph.h
index 6f2ee79..2f8843d 100644
--- a/rotord/src/graph.h
+++ b/rotord/src/graph.h
@@ -97,6 +97,43 @@ 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(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;
+ }
+ }
+ }
+ //if not svg feed to FFMS2
if (player.open(inputfilename)){
if (player.fetch_frame(w,h,player.get_number_frames()/4)) {
Image i;
@@ -105,7 +142,6 @@ namespace Rotor {
cvtColor(i.rgb,cp,CV_RGB2BGR);
cv::imwrite(outputfilename.c_str(),cp);
return true;
-
}
}
return false;