diff --git a/CHANGELOG.md b/CHANGELOG.md index 89259e4a9..ccf54090a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file. - [#1396], [#1254] FLA Export - AS3 frame scripts - FLA Export - mutliple FrameLabel layers - [#1636] Nullpointer exception on empty editorpane +- [#1156] Rendering - 9 slice scaling (DefineScalingGrid) clipping ## [14.1.0] - 2021-03-05 ### Added diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineScalingGridTag.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineScalingGridTag.java index 2e9e12a4e..d238af5de 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineScalingGridTag.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/tags/DefineScalingGridTag.java @@ -12,7 +12,8 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library. */ + * License along with this library. + */ package com.jpexs.decompiler.flash.tags; import com.jpexs.decompiler.flash.SWF; @@ -200,29 +201,12 @@ public class DefineScalingGridTag extends Tag implements CharacterIdTag { } for (int i = 0; i < targetRect.length; i++) { - - /* sourceRect[i].xMax = roundPixels20(sourceRect[i].xMax); - sourceRect[i].yMax = roundPixels20(sourceRect[i].yMax); - sourceRect[i].xMin = roundPixels20(sourceRect[i].xMin); - sourceRect[i].yMin = roundPixels20(sourceRect[i].yMin); - */ - //System.out.println("source[" + i + "]=" + sourceRect[i]); - //System.out.println("target[" + i + "]=" + targetRect[i]); - - /*targetRect[i].xMax = roundPixels20(targetRect[i].xMax); - targetRect[i].yMax = roundPixels20(targetRect[i].yMax); - targetRect[i].xMin = roundPixels20(targetRect[i].xMin); - targetRect[i].yMin = roundPixels20(targetRect[i].yMin); - */ transforms[i] = rectToRectMatrix(sourceRect[i], targetRect[i]); targetRect[i].xMax = Math.rint(targetRect[i].xMax / SWF.unitDivisor); targetRect[i].yMax = Math.rint(targetRect[i].yMax / SWF.unitDivisor); targetRect[i].xMin = Math.rint(targetRect[i].xMin / SWF.unitDivisor); targetRect[i].yMin = Math.rint(targetRect[i].yMin / SWF.unitDivisor); - - //targetRect[i].xMax += maxStroke; - //Round to pixel boundary } } } diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java index a656b32cf..1606f6c34 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/timeline/Timeline.java @@ -916,15 +916,32 @@ public class Timeline { DefineScalingGridTag.getSlices(targetBoundsRect, boundsRect, new ExportRectangle(scalingRect), sourceRect, targetRect, transforms); Shape c = g.getClip(); AffineTransform origTransform = g.getTransform(); - for (int s = 0; s < 9; s++) { - g.setTransform(new AffineTransform()); - ExportRectangle p1 = transformation.transform(targetRect[s]); - g.setClip(c); + int s = 0; + for (int sy = 0; sy < 3; sy++) { + for (int sx = 0; sx < 3; sx++) { + g.setTransform(new AffineTransform()); + ExportRectangle p1 = transformation.transform(targetRect[s]); + g.setClip(c); - Rectangle2D r = new Rectangle2D.Double(p1.xMin, p1.yMin, p1.getWidth(), p1.getHeight()); - g.setClip(r); - drawDrawable(strokeTransformation.preConcatenate(layerMatrix), layer, transforms[s], g, colorTransform, layer.blendMode, clips, transformation, isClip, layer.clipDepth, absMat, time, layer.ratio, renderContext, image, (DrawableTag) character, layer.filters, unzoom, clrTrans); + if (sx == 0) { + p1.xMin = 0; + } + if (sy == 0) { + p1.yMin = 0; + } + if (sx == 2) { + p1.xMax = Integer.MAX_VALUE; + } + if (sy == 2) { + p1.yMax = Integer.MAX_VALUE; + } + + Rectangle2D r = new Rectangle2D.Double(p1.xMin, p1.yMin, p1.getWidth(), p1.getHeight()); + g.setClip(r); + drawDrawable(strokeTransformation.preConcatenate(layerMatrix), layer, transforms[s], g, colorTransform, layer.blendMode, clips, transformation, isClip, layer.clipDepth, absMat, time, layer.ratio, renderContext, image, (DrawableTag) character, layer.filters, unzoom, clrTrans); + s++; + } } g.setClip(c); @@ -964,7 +981,8 @@ public class Timeline { } } - g.setTransform(new AffineTransform()); + g.setTransform( + new AffineTransform()); g.setClip(prevClip); }