diff --git a/src/svgeditor/BitmapEdit.as b/src/svgeditor/BitmapEdit.as index 9b8117c..83f070c 100644 --- a/src/svgeditor/BitmapEdit.as +++ b/src/svgeditor/BitmapEdit.as @@ -103,7 +103,7 @@ public class BitmapEdit extends ImageEdit { var toolsLayer:Sprite = getToolsLayer(); var contentLayer:Sprite = workArea.getContentLayer(); var p:Point = contentLayer.globalToLocal(toolsLayer.localToGlobal(toolsP)); - var roundedP:Point = new Point(2 * Math.round(p.x / 2), 2 * Math.round(p.y / 2)); // round to nearest half pixel + var roundedP:Point = workArea.getScale() == 1 ? new Point(Math.round(p.x), Math.round(p.y)) : new Point(Math.round(p.x * 2) / 2, Math.round(p.y * 2) / 2); return toolsLayer.globalToLocal(contentLayer.localToGlobal(roundedP)); } @@ -112,7 +112,7 @@ public class BitmapEdit extends ImageEdit { r = r.intersection(bm.rect); // constrain selection to bitmap content if ((r.width < 1) || (r.height < 1)) return null; // empty rectangle - var selectionBM:BitmapData = new BitmapData(r.width, r.height, true, 0);; + var selectionBM:BitmapData = new BitmapData(r.width, r.height, true, 0); selectionBM.copyPixels(bm, r, new Point(0, 0)); if (stampMode) { highlightTool('bitmapSelect'); diff --git a/src/svgeditor/tools/ObjectTransformer.as b/src/svgeditor/tools/ObjectTransformer.as index a0b232f..8e655b6 100644 --- a/src/svgeditor/tools/ObjectTransformer.as +++ b/src/svgeditor/tools/ObjectTransformer.as @@ -615,11 +615,11 @@ package svgeditor.tools { if(moveOffset) { x = parent.mouseX - moveOffset.x; y = parent.mouseY - moveOffset.y; - if(editor is BitmapEdit) { - var toolsP:Point = editor.snapToGrid(toolsLayer.globalToLocal(parent.localToGlobal(new Point(x, y)))); - var parentP:Point = parent.globalToLocal(toolsLayer.localToGlobal(toolsP)); - x = parentP.x; - y = parentP.y; + if (editor is BitmapEdit) { + var p:Point = toolsLayer.globalToLocal(localToGlobal(new Point(topLeftHandle.x, topLeftHandle.y))); + var snapped:Point = editor.snapToGrid(p); + x += snapped.x - p.x; + y += snapped.y - p.y; } updateTarget(); } else { @@ -805,9 +805,10 @@ package svgeditor.tools { // Compute the selection rectangle relative to the bitmap content. var contentP:Point = contentLayer.globalToLocal(toolsLayer.localToGlobal(rect.topLeft)); var scale:Number = editor.getWorkArea().getScale(); + // trace(contentP.x, contentP.y, rect.width, rect.height, scale); var r:Rectangle = new Rectangle( - 2 * Math.floor(contentP.x), 2 * Math.floor(contentP.y), - 2 * Math.ceil(rect.width / scale), 2 * Math.ceil(rect.height / scale)); + Math.floor(contentP.x * 2), Math.floor(contentP.y * 2), + Math.ceil(rect.width / scale * 2), Math.ceil(rect.height / scale * 2)); var selectedBM:SVGBitmap = (editor as BitmapEdit).getSelection(r); if (selectedBM) select(new Selection([selectedBM])); } else {