From f60e929d78874faac080f37d826ea4021bf01cb3 Mon Sep 17 00:00:00 2001 From: twanvl Date: Fri, 21 Sep 2007 10:13:57 +0000 Subject: [PATCH] Fixed zoom crash; Fixed crash when mising symbol font git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@725 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/gfx/generated_image.cpp | 6 ++++-- src/gfx/mask_image.cpp | 2 +- src/render/value/image.cpp | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gfx/generated_image.cpp b/src/gfx/generated_image.cpp index b1923c40..d3e483e2 100644 --- a/src/gfx/generated_image.cpp +++ b/src/gfx/generated_image.cpp @@ -85,9 +85,11 @@ Image conform_image(const Image& img, const GeneratedImage::Options& options) { // ----------------------------------------------------------------------------- : BlankImage Image BlankImage::generate(const Options& opt) const { - Image img(opt.width, opt.height); + int w = max(1, opt.width >= 0 ? opt.width : opt.height); + int h = max(1, opt.height >= 0 ? opt.height : opt.width); + Image img(w, h); img.InitAlpha(); - memset(img.GetAlpha(), 0, opt.width * opt.height); + memset(img.GetAlpha(), 0, w * h); return img; } bool BlankImage::operator == (const GeneratedImage& that) const { diff --git a/src/gfx/mask_image.cpp b/src/gfx/mask_image.cpp index 31f81ded..ef203305 100644 --- a/src/gfx/mask_image.cpp +++ b/src/gfx/mask_image.cpp @@ -44,7 +44,7 @@ void AlphaMask::setAlpha(Bitmap& bmp) const { } bool AlphaMask::isTransparent(int x, int y) const { - assert(x >= 0 && y >= 0 && x < size.GetWidth() && y < size.GetHeight()); + if (x < 0 || y > 0 || x >= size.x || y >= size.y) return false; return alpha[x + y * size.GetWidth()] < 20; } diff --git a/src/render/value/image.cpp b/src/render/value/image.cpp index de8b8974..1f7116fa 100644 --- a/src/render/value/image.cpp +++ b/src/render/value/image.cpp @@ -110,7 +110,8 @@ bool ImageValueViewer::containsPoint(const RealPoint& p) const { // check against mask if (!style().mask_filename().empty()) { loadMask(viewer.getRotation()); - return !alpha_mask || !alpha_mask->isTransparent((int)x, (int)y); + Rotation rot = viewer.getRotation(); + return !alpha_mask || !alpha_mask->isTransparent((int)rot.trX(x), (int)rot.trY(y)); } else { return true; }