Sorry about the overly complicated description. Here is a patch that fixes the problem for me. It should not break any working document and -- as I believe -- restore the old behavior.
-------- Original-Nachricht -------- > Datum: Fri, 3 Dec 2010 14:56:25 +0100 > Von: Gubinelli Massimiliano <[email protected]> > An: [email protected] > Betreff: Re: [Texmacs-dev] gs_to_png broken -- how to fix? > Hi Norbert, > I'm not quite able to follow your description now but the code in Qt > is broken with respect positioning of ps images so if you can fix it > that would be nice. As a comparison, the X11 code should be considered > correct (unless you remark also there some inconsistencies). I think > the most important thing is to preserve appearence of old documents > (again unless hard arguments are put forward against). > > best > max > > > On 3 déc. 10, at 14:52, Norbert Nemec wrote: > > > Hi there, > > > > i just wondered why several old documents that used to work fine do > > not properly display the linked EPS images any more. I identified > > the problem as an inconsistency in using Ghostscript: > > > > The routine gs_image_size uses 'gs -sDEVICE=bbox' to obtain the > > image size. This command ignores the bbox saved in the header of the > > eps image and instead analyses the contents to find the smallest > > rectangle containing the image. > > > > Lateron the image is scaled with gs setting the computed resolution > > via the '-r' option. In this context, Ghostscript honors the bbox in > > the EPS header. > > > > The result is that EPS files that contain an empty border within the > > specified bounding box around the actual content are displayed > > shifted and cropped within TeXmacs. > > > > Before trying to fix this inconsistency: what behavior is intended? > > Should the specified bbox be honored or should TeXmacs determine the > > bbox from the content? > > > > Perhaps, the best solution would be to honor an existing bbox and > > determine the bbox from the content if none is given within the EPS > > file. This may cause problems with EPS files that specify a bad > > bbox, but at least it will work correctly with intentionally non- > > minimal bbox settings. > > > > Opinions? > > > > Norbert Nemec > > -- > > Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief! > > Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail > > > > _______________________________________________ > > Texmacs-dev mailing list > > [email protected] > > http://lists.gnu.org/mailman/listinfo/texmacs-dev > > > _______________________________________________ > Texmacs-dev mailing list > [email protected] > http://lists.gnu.org/mailman/listinfo/texmacs-dev -- GMX DSL Doppel-Flat ab 19,99 €/mtl.! Jetzt auch mit gratis Notebook-Flat! http://portal.gmx.net/de/go/dsl
>From 0eea8c36d0518005ed069e1fec538141fb2ce58e Mon Sep 17 00:00:00 2001 From: Norbert Nemec <[email protected]> Date: Fri, 3 Dec 2010 15:14:53 +0100 Subject: [PATCH] Fix eps_to_png to read bbox from file --- src/src/Plugins/Ghostscript/gs_utilities.cpp | 30 +++++++++++++++---------- 1 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/src/Plugins/Ghostscript/gs_utilities.cpp b/src/src/Plugins/Ghostscript/gs_utilities.cpp index 859decc..7459b7d 100644 --- a/src/src/Plugins/Ghostscript/gs_utilities.cpp +++ b/src/src/Plugins/Ghostscript/gs_utilities.cpp @@ -25,17 +25,25 @@ gs_supports (url image) { void gs_image_size (url image, int& w_pt, int& h_pt) { -#if defined (__MINGW__) || defined (__MINGW32__) - string cmd= "\""; - cmd << get_env ("TEXMACS_PATH") << string ("\\bin\\gswin32c\" "); -#else - string cmd= "gs "; -#endif - cmd << "-dQUIET -dNOPAUSE -dBATCH -dSAFER -dEPSCrop -sDEVICE=bbox "; + string cmd; + cmd= "grep -m 1 '^%%BoundingBox: ' "; cmd << sys_concretize (image); string buf= eval_system (cmd); int pos= 0; int ok= read (buf, pos, "%%BoundingBox: "); + if (!ok) { +#if defined (__MINGW__) || defined (__MINGW32__) + cmd= "\""; + cmd << get_env ("TEXMACS_PATH") << string ("\\bin\\gswin32c\" "); +#else + cmd= "gs "; +#endif + cmd << "-dQUIET -dNOPAUSE -dBATCH -dSAFER -dEPSCrop -sDEVICE=bbox "; + cmd << sys_concretize (image); + string buf= eval_system (cmd); + int pos= 0; + int ok= read (buf, pos, "%%BoundingBox: "); + } if (ok) { int x1, y1, x2, y2; skip_spaces (buf, pos); @@ -69,12 +77,10 @@ gs_to_png (url image, url png, int w, int h) { cmd << "-sDEVICE=png16m -dGraphicsAlphaBits=4 -dEPSCrop "; cmd << "-g" << as_string (w) << "x" << as_string (h) << " "; int bbw, bbh; - double rw, rh; + int rw, rh; gs_image_size (image, bbw, bbh); - rw= (double)w*72/bbw; - rh= (double)h*72/bbh; - if ((int)rw < rw) rw= (int)rw+1; else rw= (int)rw; - if ((int)rh < rh) rh= (int)rh+1; else rh= (int)rh; + rw= (w*72-1)/bbw+1; + rh= (h*72-1)/bbh+1; cmd << "-r" << as_string (rw) << "x" << as_string (rh) << " "; cmd << "-sOutputFile=" << sys_concretize (png) << " "; cmd << sys_concretize (image); -- 1.7.1
_______________________________________________ Texmacs-dev mailing list [email protected] http://lists.gnu.org/mailman/listinfo/texmacs-dev
