summaryrefslogtreecommitdiffstats
path: root/tdehtml/rendering/render_image.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tdehtml/rendering/render_image.cpp')
-rw-r--r--tdehtml/rendering/render_image.cpp46
1 files changed, 29 insertions, 17 deletions
diff --git a/tdehtml/rendering/render_image.cpp b/tdehtml/rendering/render_image.cpp
index ad8f18bb3..18bc62aed 100644
--- a/tdehtml/rendering/render_image.cpp
+++ b/tdehtml/rendering/render_image.cpp
@@ -38,6 +38,7 @@
#include "misc/helper.h"
#include "misc/htmlattrs.h"
#include "misc/loader.h"
+#include "misc/svgrender.h"
#include "misc/htmltags.h"
#include "html/html_formimpl.h"
#include "html/html_imageimpl.h"
@@ -240,7 +241,7 @@ void RenderImage::paint(PaintInfo& paintInfo, int _tx, int _ty)
? m_oldImage : m_cachedImage;
// paint frame around image as long as it is not completely loaded from web.
- if (bUnfinishedImageFrame && paintInfo.phase == PaintActionForeground && cWidth > 2 && cHeight > 2 && !complete()) {
+ if (bUnfinishedImageFrame && paintInfo.phase == PaintActionForeground && cWidth > 2 && cHeight > 2 && !complete() && !i->isVectorImage()) {
static TQPixmap *loadingIcon;
TQColor bg = tdehtml::retrieveBackgroundColor(this);
TQColor fg = tdehtml::hasSufficientContrast(Qt::gray, bg) ? Qt::gray :
@@ -297,31 +298,42 @@ void RenderImage::paint(PaintInfo& paintInfo, int _tx, int _ty)
if (resizeCache.isNull() && cWidth && cHeight && intrinsicWidth() && intrinsicHeight())
{
TQRect scaledrect(i->valid_rect());
+ scaledrect.setWidth( ( cWidth*scaledrect.width() ) / intrinsicWidth() );
+ scaledrect.setHeight( ( cHeight*scaledrect.height() ) / intrinsicHeight() );
// kdDebug(6040) << "time elapsed: " << dt->elapsed() << endl;
// kdDebug( 6040 ) << "have to scale: " << endl;
// tqDebug("cw=%d ch=%d pw=%d ph=%d rcw=%d, rch=%d",
// cWidth, cHeight, intrinsicWidth(), intrinsicHeight(), resizeCache.width(), resizeCache.height());
- TQWMatrix matrix;
- matrix.scale( (float)(cWidth)/intrinsicWidth(),
- (float)(cHeight)/intrinsicHeight() );
- resizeCache = pix.xForm( matrix );
- scaledrect.setWidth( ( cWidth*scaledrect.width() ) / intrinsicWidth() );
- scaledrect.setHeight( ( cHeight*scaledrect.height() ) / intrinsicHeight() );
+ if(i->isVectorImage())
+ {
+ TQImage newRender = renderSVG(i->svg(), i->svgExtension(), cWidth, cHeight);
+ if(!resizeCache.convertFromImage(newRender))
+ {
+ kdDebug(6040) << "Could not convert TQImage of rendered SVG to TQPixmap!" << endl;
+ }
+ }
+ else
+ {
+ TQWMatrix matrix;
+ matrix.scale( (float)(cWidth)/intrinsicWidth(),
+ (float)(cHeight)/intrinsicHeight() );
+ resizeCache = pix.xForm( matrix );
// tqDebug("resizeCache size: %d/%d", resizeCache.width(), resizeCache.height());
// tqDebug("valid: %d/%d, scaled: %d/%d",
// i->valid_rect().width(), i->valid_rect().height(),
// scaledrect.width(), scaledrect.height());
- // sometimes scaledrect.width/height are off by one because
- // of rounding errors. if the i is fully loaded, we
- // make sure that we don't do unnecessary resizes during painting
- TQSize s(scaledrect.size());
- if(i->valid_rect().size() == TQSize( intrinsicWidth(), intrinsicHeight() )) // fully loaded
- s = TQSize(cWidth, cHeight);
- if(kAbs(s.width() - cWidth) < 2) // rounding errors
- s.setWidth(cWidth);
- if(resizeCache.size() != s)
- resizeCache.resize(s);
+ // sometimes scaledrect.width/height are off by one because
+ // of rounding errors. if the i is fully loaded, we
+ // make sure that we don't do unnecessary resizes during painting
+ TQSize s(scaledrect.size());
+ if(i->valid_rect().size() == TQSize( intrinsicWidth(), intrinsicHeight() )) // fully loaded
+ s = TQSize(cWidth, cHeight);
+ if(kAbs(s.width() - cWidth) < 2) // rounding errors
+ s.setWidth(cWidth);
+ if(resizeCache.size() != s)
+ resizeCache.resize(s);
+ }
paintInfo.p->drawPixmap( TQPoint( _tx + leftBorder + leftPad, _ty + topBorder + topPad),
resizeCache, scaledrect );