From 2158be80fe29390ca627fd40e85db5759cd77e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sun, 21 Jul 2024 17:56:51 +0200 Subject: [PATCH] Fixed #2253 Drawing 0,0 grid in transform tool on Linux causing sun internal errors --- CHANGELOG.md | 2 ++ .../decompiler/flash/gui/ImagePanel.java | 22 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f939bf754..b1f398769 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ All notable changes to this project will be documented in this file. - [PR191] Saving class name during AS3 P-code class trait editation - [#2231] AS3 coercion to String as convert - [#2257] Shape SVG Importer - Linear gradient matrix +- [#2253] Drawing 0,0 grid in transform tool on Linux causing sun internal errors ### Changed - [#2185] MochiCrypt no longer offered for auto decrypt, user needs to choose variant from "Use unpacker" menu @@ -3416,6 +3417,7 @@ Major version of SWF to XML export changed to 2. [#2224]: https://www.free-decompiler.com/flash/issues/2224 [#2231]: https://www.free-decompiler.com/flash/issues/2231 [#2257]: https://www.free-decompiler.com/flash/issues/2257 +[#2253]: https://www.free-decompiler.com/flash/issues/2253 [#2206]: https://www.free-decompiler.com/flash/issues/2206 [#2100]: https://www.free-decompiler.com/flash/issues/2100 [#2123]: https://www.free-decompiler.com/flash/issues/2123 diff --git a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java index 21d5da832..6aed03c12 100644 --- a/src/com/jpexs/decompiler/flash/gui/ImagePanel.java +++ b/src/com/jpexs/decompiler/flash/gui/ImagePanel.java @@ -754,6 +754,8 @@ public final class ImagePanel extends JPanel implements MediaDisplay { private Point2D dragStart = null; private Point2D selectionEnd = null; + + private boolean canInvert = true; private Rectangle2D getSelectionRect() { Point2D selectStart = dragStart; @@ -936,7 +938,11 @@ public final class ImagePanel extends JPanel implements MediaDisplay { RECT timRect = timelined.getRect(); axisX = (int) Math.round(offsetPoint.getX()); axisY = (int) Math.round(offsetPoint.getY()); - g2.setComposite(BlendComposite.Invert); + if (canInvert) { + g2.setComposite(BlendComposite.Invert); + } else { + g2.setComposite(AlphaComposite.SrcOver); + } g2.setPaint(new Color(255, 255, 255, 128)); float dp; dp = -(float) offsetPoint.getY(); @@ -963,11 +969,23 @@ public final class ImagePanel extends JPanel implements MediaDisplay { Rectangle2D selectionRect = getSelectionRect(); if (selectionRect != null) { g2.setStroke(new BasicStroke(1, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND, 0, new float[]{2, 2}, 0f)); - g2.setComposite(BlendComposite.Invert); + if (canInvert) { + g2.setComposite(BlendComposite.Invert); + } else { + g2.setComposite(AlphaComposite.SrcOver); + } g2.draw(new Rectangle2D.Double(selectionRect.getX(), selectionRect.getY(), selectionRect.getWidth(), selectionRect.getHeight())); g2.setComposite(AlphaComposite.SrcOver); } } + } catch (InternalError ie) { + //On some devices like Linux X11 - BlendComposite.Invert is not available + //since sun.java2d.xr.XRSurfaceData.getRaster(XRSurfaceData.java:72) is not implemented + // (tried in WSL) + if (canInvert) { + canInvert = false; + continue; + } } finally { if (g2 != null) { g2.dispose();