X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fsvg%2Fsvg.C;h=89499d15c7bb9c4d5ae5c6308ba29f8248467125;hp=27881f2c9fb2fae6cbde15b5811b37c058c1ea70;hb=723142d62d61cde588e961426440f839ca9dcda9;hpb=7be8c7f90868895abddcbafda66ede5632752a70 diff --git a/cinelerra-5.1/plugins/svg/svg.C b/cinelerra-5.1/plugins/svg/svg.C index 27881f2c..89499d15 100644 --- a/cinelerra-5.1/plugins/svg/svg.C +++ b/cinelerra-5.1/plugins/svg/svg.C @@ -2,17 +2,17 @@ /* * CINELERRA * Copyright (C) 2008 Adam Williams - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -97,7 +97,7 @@ SvgMain::~SvgMain() delete overlayer; } -const char* SvgMain::plugin_title() { return _("SVG via Inkscape"); } +const char* SvgMain::plugin_title() { return N_("SVG via Inkscape"); } int SvgMain::is_realtime() { return 1; } int SvgMain::is_synthesis() { return 1; } @@ -178,7 +178,7 @@ int SvgMain::process_realtime(VFrame *input, VFrame *output) int fd = ms_time < config.ms_time ? -1 : open(filename_png, O_RDWR); if( fd < 0 ) { // file does not exist, export it char command[BCTEXTLEN]; - sprintf(command, + snprintf(command, sizeof(command), "inkscape --without-gui --export-background=0x000000 " "--export-background-opacity=0 -d %f %s --export-png=%s", config.dpi, config.svg_file, filename_png); @@ -190,29 +190,17 @@ int SvgMain::process_realtime(VFrame *input, VFrame *output) printf(_("Export of %s to %s failed\n"), config.svg_file, filename_png); } if( fd >= 0 ) { - struct stat st_png; - fstat(fd, &st_png); - unsigned char *png_buffer = (unsigned char *) - mmap (NULL, st_png.st_size, PROT_READ, MAP_SHARED, fd, 0); - if( png_buffer != MAP_FAILED ) { - if( png_buffer[0] == 0x89 && png_buffer[1] == 0x50 && - png_buffer[2] == 0x4e && png_buffer[3] == 0x47 ) { - ofrm = new VFramePng(png_buffer, st_png.st_size, 1., 1.); - if( ofrm->get_color_model() != output->get_color_model() ) { - VFrame *vfrm = new VFrame(ofrm->get_w(), ofrm->get_h(), - output->get_color_model()); - vfrm->transfer_from(ofrm); - delete ofrm; ofrm = vfrm; - } - } - else - printf (_("The file %s that was generated from %s is not in PNG format." - " Try to delete all *.png files.\n"), filename_png, config.svg_file); - munmap(png_buffer, st_png.st_size); - } - else - printf(_("Access mmap to %s as %s failed.\n"), config.svg_file, filename_png); + ofrm = VFramePng::vframe_png(fd); close(fd); + if( ofrm && ofrm->get_color_model() != output->get_color_model() ) { + VFrame *vfrm = new VFrame(ofrm->get_w(), ofrm->get_h(), + output->get_color_model(), 0); + vfrm->transfer_from(ofrm); + delete ofrm; ofrm = vfrm; + } + if( !ofrm ) + printf (_("The file %s that was generated from %s is not in PNG format." + " Try to delete all *.png files.\n"), filename_png, config.svg_file); } } if( ofrm ) {