getting there... I have a graphics cache that ALWAYS stores the image data, but only starts loading the image if it receives an explicit request to do so from InsetGraphics::draw(). Moreover, if the InsetGraphicsParams::display variable is set to NONE, then it's intelligent enough not to start the slog.
This means that I can also move the conversion part of InsetGraphics::prepareFile() into the graphics cache. Again, where it belongs. No need to convert multiple copies of the same file. My question: if the output file needs to be converted (to eps, png etc), then this conversion is always going to result in bitmap (rather than vector) data. So, does it matter if we start from the original file, or from the pixmap stored in memory (if it has been created). Note, we store two copies of the image. The original one without any scaling, cropping, rotation and the one modified for the LyX screen. So, I'm suggesting simply exporting the original, unmodified XPM file to EPS, etc and then letting includegraphics do the scaling etc for the final output. Note that the original file is loaded as COLOR always. Displaying as MONO or GRAYSCALE in LyX count as modifications. Means that we can switch display states v. quickly and also that the output file will be as expected. The alternative is to simply pass GraphicsCacheItem::convert(filename) the output format and let it re-invent the wheel. What say you? Angus