namespace lyx {
namespace graphics {
-/// Access to this class is through this static method.
-Image * GuiImage::newImage()
+/// Implement factory method defined in GraphicsImage.h
+Image * newImage()
{
return new GuiImage;
}
LYXERR(Debug::GRAPHICS, "Image is loaded already!");
return false;
}
- fname_ = toqstr(filename.absFilename());
+ fname_ = toqstr(filename.absFileName());
return load();
}
LYXERR(Debug::GRAPHICS, "Unable to open image");
return false;
}
- original_.detach();
return true;
}
is_transformed_ |= scale(params);
// Clear the pixmap to save some memory.
- if (is_transformed_) {
- original_.detach();
+ if (is_transformed_)
original_ = QImage();
- } else {
- transformed_.detach();
+ else
transformed_ = QImage();
- }
return true;
}
{
QImage const & image = is_transformed_ ? transformed_ : original_;
- unsigned int w = image.width();
- unsigned int h = image.height();
+ if (params.scale == 100)
+ return false;
- // scale only when value > 0
- if (params.scale > 0) {
- w = (w * params.scale) / 100;
- h = (h * params.scale) / 100;
- }
+ qreal scale = qreal(params.scale) / 100.0;
- LYXERR(Debug::GRAPHICS, "\n\tparams.scale : " << params.scale
- << "\n\twidth : " << w
- << "\n\theight : " << h);
+#if (QT_VERSION >= 0x040500) && (QT_VERSION <= 0x040502)
+ // Due to a bug in Qt, LyX will crash for certain
+ // scaling factors and sizes of the image.
+ // see bug #5957: http://www.lyx.org/trac/ticket/5957
+ scale += 0.0001;
+#endif
- if (w == image.width() && h == image.height())
- return false;
-
QMatrix m;
- m.scale(double(w) / image.width(), double(h) / image.height());
+ m.scale(scale, scale);
transformed_ = image.transformed(m);
return true;
}