diff options
| author | buliabyak <> | 2013-10-03 23:50:06 +0000 |
|---|---|---|
| committer | buliabyak <> | 2013-10-03 23:50:06 +0000 |
| commit | 03eb26c89db28d9d3a6568c1141046f734715b62 (patch) | |
| tree | 664622778774f25135fe0e07636d5a5b5c969fa4 /src/sp-image.cpp | |
| parent | FIXME comment (diff) | |
| download | inkscape-03eb26c89db28d9d3a6568c1141046f734715b62.tar.gz inkscape-03eb26c89db28d9d3a6568c1141046f734715b62.zip | |
if this->pixbuf check must come earlier to prevent crash
(bzr r12653)
Diffstat (limited to 'src/sp-image.cpp')
| -rw-r--r-- | src/sp-image.cpp | 132 |
1 files changed, 67 insertions, 65 deletions
diff --git a/src/sp-image.cpp b/src/sp-image.cpp index f2fc6a37a..86668d9ed 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -433,73 +433,75 @@ void SPImage::update(SPCtx *ctx, unsigned int flags) { this->ox = this->x.computed; this->oy = this->y.computed; - int pixwidth = this->pixbuf->width(); - int pixheight = this->pixbuf->height(); - - this->sx = this->width.computed / pixwidth; - this->sy = this->height.computed / pixheight; - - // preserveAspectRatio calculate bounds / clipping rectangle -- EAF - if (this->pixbuf && (this->aspect_align != SP_ASPECT_NONE)) { - double x, y; - - switch (this->aspect_align) { - case SP_ASPECT_XMIN_YMIN: - x = 0.0; - y = 0.0; - break; - case SP_ASPECT_XMID_YMIN: - x = 0.5; - y = 0.0; - break; - case SP_ASPECT_XMAX_YMIN: - x = 1.0; - y = 0.0; - break; - case SP_ASPECT_XMIN_YMID: - x = 0.0; - y = 0.5; - break; - case SP_ASPECT_XMID_YMID: - x = 0.5; - y = 0.5; - break; - case SP_ASPECT_XMAX_YMID: - x = 1.0; - y = 0.5; - break; - case SP_ASPECT_XMIN_YMAX: - x = 0.0; - y = 1.0; - break; - case SP_ASPECT_XMID_YMAX: - x = 0.5; - y = 1.0; - break; - case SP_ASPECT_XMAX_YMAX: - x = 1.0; - y = 1.0; - break; - default: - x = 0.0; - y = 0.0; - break; - } + if (this->pixbuf) { + int pixwidth = this->pixbuf->width(); + int pixheight = this->pixbuf->height(); - if (this->aspect_clip == SP_ASPECT_SLICE) { - double scale = std::max(this->sx, this->sy); - this->sx = scale; - this->sy = scale; - } else { - double scale = std::min(this->sx, this->sy); - this->sx = scale; - this->sy = scale; - } + this->sx = this->width.computed / pixwidth; + this->sy = this->height.computed / pixheight; + + // preserveAspectRatio calculate bounds / clipping rectangle -- EAF + if (this->aspect_align != SP_ASPECT_NONE) { + double x, y; - double vw = pixwidth * this->sx; - double vh = pixheight * this->sy; - this->ox += x * (this->width.computed - vw); - this->oy += y * (this->height.computed - vh); + switch (this->aspect_align) { + case SP_ASPECT_XMIN_YMIN: + x = 0.0; + y = 0.0; + break; + case SP_ASPECT_XMID_YMIN: + x = 0.5; + y = 0.0; + break; + case SP_ASPECT_XMAX_YMIN: + x = 1.0; + y = 0.0; + break; + case SP_ASPECT_XMIN_YMID: + x = 0.0; + y = 0.5; + break; + case SP_ASPECT_XMID_YMID: + x = 0.5; + y = 0.5; + break; + case SP_ASPECT_XMAX_YMID: + x = 1.0; + y = 0.5; + break; + case SP_ASPECT_XMIN_YMAX: + x = 0.0; + y = 1.0; + break; + case SP_ASPECT_XMID_YMAX: + x = 0.5; + y = 1.0; + break; + case SP_ASPECT_XMAX_YMAX: + x = 1.0; + y = 1.0; + break; + default: + x = 0.0; + y = 0.0; + break; + } + + if (this->aspect_clip == SP_ASPECT_SLICE) { + double scale = std::max(this->sx, this->sy); + this->sx = scale; + this->sy = scale; + } else { + double scale = std::min(this->sx, this->sy); + this->sx = scale; + this->sy = scale; + } + + double vw = pixwidth * this->sx; + double vh = pixheight * this->sy; + this->ox += x * (this->width.computed - vw); + this->oy += y * (this->height.computed - vh); + } } sp_image_update_canvas_image ((SPImage *) this); } |
