Commit 817b95b6 authored by twanvl's avatar twanvl

Fixed zoom crash;

Fixed crash when mising symbol font
parent 189c4c20
...@@ -85,9 +85,11 @@ Image conform_image(const Image& img, const GeneratedImage::Options& options) { ...@@ -85,9 +85,11 @@ Image conform_image(const Image& img, const GeneratedImage::Options& options) {
// ----------------------------------------------------------------------------- : BlankImage // ----------------------------------------------------------------------------- : BlankImage
Image BlankImage::generate(const Options& opt) const { 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(); img.InitAlpha();
memset(img.GetAlpha(), 0, opt.width * opt.height); memset(img.GetAlpha(), 0, w * h);
return img; return img;
} }
bool BlankImage::operator == (const GeneratedImage& that) const { bool BlankImage::operator == (const GeneratedImage& that) const {
......
...@@ -44,7 +44,7 @@ void AlphaMask::setAlpha(Bitmap& bmp) const { ...@@ -44,7 +44,7 @@ void AlphaMask::setAlpha(Bitmap& bmp) const {
} }
bool AlphaMask::isTransparent(int x, int y) 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; return alpha[x + y * size.GetWidth()] < 20;
} }
......
...@@ -110,7 +110,8 @@ bool ImageValueViewer::containsPoint(const RealPoint& p) const { ...@@ -110,7 +110,8 @@ bool ImageValueViewer::containsPoint(const RealPoint& p) const {
// check against mask // check against mask
if (!style().mask_filename().empty()) { if (!style().mask_filename().empty()) {
loadMask(viewer.getRotation()); 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 { } else {
return true; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment