=== modified file 'src/extension/internal/emf-inout.cpp' --- src/extension/internal/emf-inout.cpp 2014-02-08 07:17:30 +0000 +++ src/extension/internal/emf-inout.cpp 2014-02-11 23:09:52 +0000 @@ -554,6 +554,7 @@ else { *(d->defs) += " xlink:href=\"data:image/png;base64,"; } *(d->defs) += base64String; *(d->defs) += "\"\n"; + *(d->defs) += " preserveAspectRatio=\"none\"\n"; *(d->defs) += " />\n"; @@ -1531,6 +1532,7 @@ tmp_image << "\"\n height=\"" << dh << "\"\n width=\"" << dw << "\"\n"; tmp_image << " transform=" << current_matrix(d, dx, dy, 1); // calculate appropriate offset + tmp_image << " preserveAspectRatio=\"none\"\n"; tmp_image << "/> \n"; *(d->outsvg) += tmp_image.str().c_str(); === modified file 'src/extension/internal/emf-print.cpp' --- src/extension/internal/emf-print.cpp 2014-02-08 07:17:30 +0000 +++ src/extension/internal/emf-print.cpp 2014-02-11 23:09:52 +0000 @@ -1562,7 +1562,7 @@ unsigned int w, /** width of bitmap */ unsigned int h, /** height of bitmap */ unsigned int rs, /** row stride (normally w*4) */ - Geom::Affine const &/*tf_ignore*/, /** WRONG affine transform, use the one from m_tr_stack */ + Geom::Affine const &tf_rect, /** affine transform only used for defining location and size of rect, for all other tranforms, use the one from m_tr_stack */ SPStyle const *style) /** provides indirect link to image object */ { double x1, y1, dw, dh; @@ -1574,10 +1574,10 @@ g_error("Fatal programming error in PrintEmf::image at EMRHEADER"); } - x1 = atof(style->object->getAttribute("x")); - y1 = atof(style->object->getAttribute("y")); - dw = atof(style->object->getAttribute("width")); - dh = atof(style->object->getAttribute("height")); + x1 = tf_rect[4]; + y1 = tf_rect[5]; + dw = ((double) w) * tf_rect[0]; + dh = ((double) h) * tf_rect[3]; Geom::Point pLL(x1, y1); Geom::Point pLL2 = pLL * tf; //location of LL corner in Inkscape coordinates === modified file 'src/extension/internal/wmf-inout.cpp' --- src/extension/internal/wmf-inout.cpp 2014-02-08 07:17:30 +0000 +++ src/extension/internal/wmf-inout.cpp 2014-02-11 23:26:16 +0000 @@ -525,6 +525,7 @@ else { *(d->defs) += " xlink:href=\"data:image/png;base64,"; } *(d->defs) += base64String; *(d->defs) += "\"\n"; + *(d->defs) += " preserveAspectRatio=\"none\"\n"; *(d->defs) += " />\n"; @@ -619,6 +620,7 @@ *(d->defs) += " xlink:href=\"data:image/png;base64,"; *(d->defs) += base64String; *(d->defs) += "\"\n"; + *(d->defs) += " preserveAspectRatio=\"none\"\n"; *(d->defs) += " />\n"; @@ -1269,6 +1271,7 @@ SVGOStringStream tmp_image; int dibparams; + tmp_image << "\n\t \n"; + *(d->outsvg) += tmp_image.str().c_str(); - - *(d->outsvg) += "/> \n"; *(d->path) = ""; } === modified file 'src/extension/internal/wmf-print.cpp' --- src/extension/internal/wmf-print.cpp 2014-01-17 23:24:11 +0000 +++ src/extension/internal/wmf-print.cpp 2014-02-11 23:09:52 +0000 @@ -1103,7 +1103,7 @@ unsigned int w, /** width of bitmap */ unsigned int h, /** height of bitmap */ unsigned int rs, /** row stride (normally w*4) */ - Geom::Affine const & /*tf_ignore*/, /** WRONG affine transform, use the one from m_tr_stack */ + Geom::Affine const &tf_rect, /** affine transform only used for defining location and size of rect, for all other tranforms, use the one from m_tr_stack */ SPStyle const *style) /** provides indirect link to image object */ { double x1, y1, dw, dh; @@ -1115,15 +1115,19 @@ g_error("Fatal programming error in PrintWmf::image at EMRHEADER"); } - x1 = g_ascii_strtod(style->object->getAttribute("x"), NULL); - y1 = g_ascii_strtod(style->object->getAttribute("y"), NULL); - dw = g_ascii_strtod(style->object->getAttribute("width"), NULL); - dh = g_ascii_strtod(style->object->getAttribute("height"), NULL); + x1 = tf_rect[4]; + y1 = tf_rect[5]; + dw = ((double) w) * tf_rect[0]; + dh = ((double) h) * tf_rect[3]; Geom::Point pLL(x1, y1); Geom::Point pLL2 = pLL * tf; //location of LL corner in Inkscape coordinates + /* adjust scale of w and h. This works properly when there is no rotation. The values are + a bit strange when there is rotation, but since WMF cannot handle rotation in any case, all + answers are equally wrong. + */ Geom::Point pWH(dw, dh); - Geom::Point pWH2 = pWH * tf.withoutTranslation(); //adjust scale + Geom::Point pWH2 = pWH * tf.withoutTranslation(); char *px; uint32_t cbPx; === modified file 'src/sp-image.cpp' --- src/sp-image.cpp 2014-02-06 14:29:15 +0000 +++ src/sp-image.cpp 2014-02-11 23:09:52 +0000 @@ -500,39 +500,15 @@ int w = pb->width(); int h = pb->height(); int rs = pb->rowstride(); - //int pixskip = gdk_pixbuf_get_n_channels(pb) * gdk_pixbuf_get_bits_per_sample(pb) / 8; - int pixskip = 4; - - if (this->aspect_align == SP_ASPECT_NONE) { - Geom::Affine t; - Geom::Translate tp(this->x.computed, this->y.computed); - Geom::Scale s(this->width.computed, -this->height.computed); - Geom::Translate ti(0.0, -1.0); - t = s * tp; - t = ti * t; - sp_print_image_R8G8B8A8_N(ctx, px, w, h, rs, t, this->style); - } else { // preserveAspectRatio - double vw = this->width.computed / this->sx; - double vh = this->height.computed / this->sy; - - int trimwidth = std::min(w, ceil(this->width.computed / vw * w)); - int trimheight = std::min(h, ceil(this->height.computed / vh * h)); - int trimx = std::max(0, floor((this->x.computed - this->ox) / vw * w)); - int trimy = std::max(0, floor((this->y.computed - this->oy) / vh * h)); - - double vx = std::max(this->ox, this->x.computed); - double vy = std::max(this->oy, this->y.computed); - double vcw = std::min(this->width.computed, vw); - double vch = std::min(this->height.computed, vh); - - Geom::Affine t; - Geom::Translate tp(vx, vy); - Geom::Scale s(vcw, -vch); - Geom::Translate ti(0.0, -1.0); - t = s * tp; - t = ti * t; - sp_print_image_R8G8B8A8_N(ctx, px + trimx*pixskip + trimy*rs, trimwidth, trimheight, rs, t, this->style); - } + + double vx = this->ox; + double vy = this->oy; + + Geom::Affine t; + Geom::Translate tp(vx, vy); + Geom::Scale s(this->sx, this->sy); + t = s * tp; + sp_print_image_R8G8B8A8_N(ctx, px, w, h, rs, t, this->style); delete pb; } }