commit ec722f3a48ee7f1c774ef504862dcea8276373df
Author: Juergen Spitzmueller <[email protected]>
Date:   Fri Dec 31 14:30:09 2021 +0100

    GuiGraphics: read the BB values also for new graphics
    
    that aren't in the cache yet.
---
 src/frontends/qt/GuiGraphics.cpp |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/frontends/qt/GuiGraphics.cpp b/src/frontends/qt/GuiGraphics.cpp
index 6a651fd..aefe3d0 100644
--- a/src/frontends/qt/GuiGraphics.cpp
+++ b/src/frontends/qt/GuiGraphics.cpp
@@ -794,16 +794,17 @@ string GuiGraphics::readBoundingBox(string const & file)
 {
        FileName const abs_file = support::makeAbsPath(file, 
fromqstr(bufferFilePath()));
 
-       // try to get it from the file, if possible. Zipped files are
-       // unzipped in the readBB_from_PSFile-Function
+       // With (E)PS files, try to get it from the file, if possible.
+       // Zipped files are unzipped in the readBB_from_PSFile-Function
        string const bb = graphics::readBB_from_PSFile(abs_file);
        if (!bb.empty())
                return bb;
 
-       // we don't, so ask the Graphics Cache if it has loaded the file
+       // With other formats, we try to read the file dimensions
        int width = 0;
        int height = 0;
 
+       // First ask the Graphics Cache if it has loaded the file
        graphics::Cache & gc = graphics::Cache::get();
        if (gc.inCache(abs_file)) {
                graphics::Image const * image = gc.item(abs_file)->image();
@@ -812,6 +813,13 @@ string GuiGraphics::readBoundingBox(string const & file)
                        width  = image->width();
                        height = image->height();
                }
+       } else {
+               // If not, construct a QImage and get the values from that
+               QImage image(toqstr(abs_file.absoluteFilePath()));
+               if (!image.isNull()) {
+                       width  = image.width();
+                       height = image.height();
+               }
        }
 
        return ("0 0 " + convert<string>(width) + ' ' + 
convert<string>(height));
-- 
lyx-cvs mailing list
[email protected]
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to