Hi, I think that everybody will agree that image rendering in TeXmacs is currently quite broken.
If I understand correctly, an imported image is first converted to eps. (I think using the scheme conversion methods). Then, when the image is displayed, src/Plugins/Ghostscript/gs_utilities.cpp Is called, which is hard coded to use gs with certain parameters. Then, when the file is exported, the image is again converted, if necessary. I think TeXmacs should keep the image in the original format, and render it from there. On printing it might be converted, or not. And, I think that image rendering should be done in the background so that TeXmacs does not get stuck every time an image is displayed.... As a temporary remedy, I added a hack... First of all, calling gs is not hard coded in TeXmacs. Instead an external script is called. (hard coded in my version ;) Since we use an external script, we can try different things... maybe use gs correctly, or some such. The script I ended up using simply calls gs exactly like TeXmacs originally did, except that it caches images. So if an image is rendered once in a certain resolution, the cached version is used, instead. The cache uses ~/.imagecache/[CRC32 of image]/img_404x449_90x90.png Where 404x449_90x90 are the requested resolutions of the image. For now, it works nicely for me. Sadly, there isn't really a facility to redraw an image when something goes wrong, so you might have to erase ~/.imagecache This whole thing is a horrible hack. But since I work with images that take 20 seconds or more to render (just a simple 50x100 density plot from R, nothing fancy), and a document will have many of those, scrolling through the document was really maddening. Anyway, here is the script and the edits. The edit to src/Plugins/Ghostscript/gs_utilities.cpp is to replace gs_to_png with: ---- void gs_to_png (url image, url png, int w, int h) { #if defined (__MINGW__) || defined (__MINGW32__) string cmd= "\""; cmd << get_env ("TEXMACS_PATH") << string ("\\bin\\gswin32c\" "); #else string cmd= "/usr/local/bin/ps_to_png "; #endif cmd << " " << as_string (w) << " " << as_string (h) << " "; int bbw, bbh; int rw, rh; gs_image_size (image, bbw, bbh); rw= (w*72-1)/bbw+1; rh= (h*72-1)/bbh+1; cmd << " " << as_string (rw) << " " << as_string (rh) << " "; cmd << " " << sys_concretize (png) << " "; cmd << sys_concretize (image); system (cmd); } ---- What do you think? Michael
ps_to_png
Description: Binary data
_______________________________________________ Texmacs-dev mailing list Texmacs-dev@gnu.org https://lists.gnu.org/mailman/listinfo/texmacs-dev