diff --git a/.gitignore b/.gitignore
index 433d00db9..5f311f11b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -90,3 +90,6 @@ exported1.all.bin
/libsrc/nellymoser/dist/
/libsrc/nellymoser/build/
/libsrc/ttf/dist/
+/libsrc/gifreader/nbproject/private/
+/libsrc/gifreader/dist/
+/libsrc/gifreader/build/
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0d5a79176..aa83fef14 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
## [Unreleased]
### Added
- [#2090] Support for Mochicrypt packed binarydata tags - loading SWF as subtree
+- [#2079] Replace DefineSprite with GIF
## [19.0.0] - 2023-10-01
### Added
@@ -3121,6 +3122,7 @@ Major version of SWF to XML export changed to 2.
[alpha 8]: https://github.com/jindrapetrik/jpexs-decompiler/compare/alpha7...alpha8
[alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7
[#2090]: https://www.free-decompiler.com/flash/issues/2090
+[#2079]: https://www.free-decompiler.com/flash/issues/2079
[#1449]: https://www.free-decompiler.com/flash/issues/1449
[#2070]: https://www.free-decompiler.com/flash/issues/2070
[#2073]: https://www.free-decompiler.com/flash/issues/2073
diff --git a/lib/gifreader.jar b/lib/gifreader.jar
new file mode 100644
index 000000000..b73989c68
Binary files /dev/null and b/lib/gifreader.jar differ
diff --git a/lib/gifreader.license.txt b/lib/gifreader.license.txt
new file mode 100644
index 000000000..e06d20818
--- /dev/null
+++ b/lib/gifreader.license.txt
@@ -0,0 +1,202 @@
+Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
diff --git a/libsrc/ffdec_lib/README.md b/libsrc/ffdec_lib/README.md
index 1d19513c6..fd6737f84 100644
--- a/libsrc/ffdec_lib/README.md
+++ b/libsrc/ffdec_lib/README.md
@@ -28,6 +28,7 @@ These include:
* DDSReader - `ddsreader.jar` - DDS images reading (GFX files)
* Reality Interactive ImageIO TGA library - `tga.jar` - TGA images reading (GFX files)
* Flashdebugger library - `flashdebugger.jar` - Flash debugging
+* Open Imaging GIF Decoder - `gifreader.jar` - Importing GIFs
## Basic library usage
```java
@@ -166,6 +167,7 @@ And also links to these libraries:
* [Reality Interactive ImageIO TGA library] (TGA file display in GFX files) - LGPL v2.1
* [flashdebugger library] (Debugging ActionScript) - LGPLv3
* [Java Native Access - JNA] (Registry association, Process memory reading) - LGPL
+* [Open Imaging GIF Decoder] (GIF file importing) - Apache License 2.0
[sfntly]: https://code.google.com/p/sfntly/
[JLayer]: http://www.javazoom.net/javalayer/javalayer.html
@@ -181,4 +183,5 @@ And also links to these libraries:
[vlcj]: https://github.com/caprica/vlcj
[Reality Interactive ImageIO TGA library]: https://github.com/tmyroadctfig/com.realityinteractive.imageio.tga
[flashdebugger library]: https://github.com/jindrapetrik/flashdebugger
-[Java Native Access - JNA]: https://github.com/twall/jna
\ No newline at end of file
+[Java Native Access - JNA]: https://github.com/twall/jna
+[Open Imaging GIF Decoder]: https://github.com/DhyanB/Open-Imaging
\ No newline at end of file
diff --git a/libsrc/ffdec_lib/lib/gifreader.jar b/libsrc/ffdec_lib/lib/gifreader.jar
new file mode 100644
index 000000000..b73989c68
Binary files /dev/null and b/libsrc/ffdec_lib/lib/gifreader.jar differ
diff --git a/libsrc/ffdec_lib/lib/gifreader.license.txt b/libsrc/ffdec_lib/lib/gifreader.license.txt
new file mode 100644
index 000000000..e06d20818
--- /dev/null
+++ b/libsrc/ffdec_lib/lib/gifreader.license.txt
@@ -0,0 +1,202 @@
+Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
diff --git a/libsrc/ffdec_lib/nbproject/project.xml b/libsrc/ffdec_lib/nbproject/project.xml
index c3c40440e..1ce049b46 100644
--- a/libsrc/ffdec_lib/nbproject/project.xml
+++ b/libsrc/ffdec_lib/nbproject/project.xml
@@ -242,7 +242,7 @@ auxiliary.show.customizer.message=
src
- ../../src;lib/LZMA.jar;lib/avi.jar;lib/cmykjpeg.jar;lib/ddsreader.jar;lib/gif.jar;lib/gnujpdf.jar;lib/jlayer-1.0.2.jar;lib/jpacker.jar;lib/nellymoser.jar;lib/sfntly.jar;lib/tga.jar;lib/ttf.jar;lib/vlcj-4.7.3.jar;lib/vlcj-natives-4.7.0.jar;lib/flashdebugger.jar;lib/jna-3.5.1.jar;lib/jna-platform-3.5.1.jar
+ ../../src;lib/LZMA.jar;lib/avi.jar;lib/cmykjpeg.jar;lib/ddsreader.jar;lib/gif.jar;lib/gnujpdf.jar;lib/jlayer-1.0.2.jar;lib/jpacker.jar;lib/nellymoser.jar;lib/sfntly.jar;lib/tga.jar;lib/ttf.jar;lib/vlcj-4.7.3.jar;lib/vlcj-natives-4.7.0.jar;lib/flashdebugger.jar;lib/jna-3.5.1.jar;lib/jna-platform-3.5.1.jar;lib/gifreader.jar
build
reports
dist
diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/SpriteImporter.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/SpriteImporter.java
new file mode 100644
index 000000000..d84387ec9
--- /dev/null
+++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/importers/SpriteImporter.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2010-2023 JPEXS, All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3.0 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library.
+ */
+package com.jpexs.decompiler.flash.importers;
+
+import at.dhyan.open_imaging.GifDecoder;
+import at.dhyan.open_imaging.GifDecoder.GifImage;
+import com.jpexs.decompiler.flash.SWF;
+import com.jpexs.decompiler.flash.tags.DefineShape2Tag;
+import com.jpexs.decompiler.flash.tags.DefineSpriteTag;
+import com.jpexs.decompiler.flash.tags.PlaceObject2Tag;
+import com.jpexs.decompiler.flash.tags.RemoveObjectTag;
+import com.jpexs.decompiler.flash.tags.ShowFrameTag;
+import com.jpexs.decompiler.flash.tags.Tag;
+import com.jpexs.decompiler.flash.tags.base.CharacterIdTag;
+import com.jpexs.decompiler.flash.tags.base.CharacterTag;
+import com.jpexs.decompiler.flash.tags.base.PlaceObjectTypeTag;
+import com.jpexs.decompiler.flash.timeline.Timelined;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import javax.imageio.ImageIO;
+
+/**
+ *
+ * @author JPEXS
+ */
+public class SpriteImporter {
+
+ private void removeCharacters(Set usedCharacters, SWF swf) {
+ for (int ch:usedCharacters) {
+ CharacterTag ct = swf.getCharacter(ch);
+ if (ct == null) {
+ continue;
+ }
+ if (!ct.getClassNames().isEmpty()) {
+ continue;
+ }
+ if (ct.getExportName() != null) {
+ continue;
+ }
+ Set dependentCharacters = swf.getDependentCharacters(ch);
+ if (dependentCharacters.isEmpty()) {
+ Set needed = new LinkedHashSet<>();
+ ct.getNeededCharacters(needed, swf);
+ List attachedTags = swf.getCharacterIdTags(ch);
+ for (CharacterIdTag cit : attachedTags) {
+ if (cit instanceof Tag) {
+ Tag citt = (Tag) cit;
+ citt.getTimelined().removeTag(citt);
+ }
+ }
+ ct.getTimelined().removeTag(ct);
+ swf.computeDependentCharacters();
+ removeCharacters(needed, swf);
+ }
+ }
+ }
+
+ public boolean importSprite(DefineSpriteTag spriteTag, InputStream is) throws IOException {
+ final GifImage gif = GifDecoder.read(is);
+ final int frameCount = gif.getFrameCount();
+ Set usedCharacters = new LinkedHashSet<>();
+ for (int i = spriteTag.getTags().size() - 1; i >= 0; i--) {
+ Tag t = spriteTag.getTags().get(i);
+ if (t instanceof PlaceObjectTypeTag) {
+ PlaceObjectTypeTag pt = (PlaceObjectTypeTag)t;
+ int characterId = pt.getCharacterId();
+ if (characterId != -1) {
+ usedCharacters.add(characterId);
+ }
+ }
+ spriteTag.removeTag(i);
+ }
+ spriteTag.getSwf().computeDependentCharacters();
+
+ removeCharacters(usedCharacters, spriteTag.getSwf());
+
+
+ ShapeImporter shapeImporter = new ShapeImporter();
+ SWF swf = spriteTag.getSwf();
+
+ float swfFrameRate = swf.frameRate;
+ int gifFrameTimeMs = 0;
+ int gifFrame = 0;
+ int swfFrame = 0;
+ int lastGifFrame = -1;
+ int gifFrameCount = gif.getFrameCount();
+ while (gifFrame < gifFrameCount) {
+
+ if (lastGifFrame != gifFrame) {
+ final BufferedImage img = gif.getFrame(gifFrame);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ImageIO.write(img, "png", baos);
+ byte frameImageData[] = baos.toByteArray();
+ DefineShape2Tag shapeTag = new DefineShape2Tag(spriteTag.getSwf());
+ SWF.addTagBefore(shapeTag, spriteTag);
+ shapeImporter.importImage(shapeTag, frameImageData, 0, false);
+
+ PlaceObject2Tag placeObject = new PlaceObject2Tag(swf);
+ placeObject.placeFlagHasCharacter = true;
+ placeObject.characterId = shapeTag.shapeId;
+ placeObject.depth = 1;
+
+ if (swfFrame > 0) {
+ placeObject.placeFlagMove = true;
+ }
+
+ spriteTag.addTag(placeObject);
+ placeObject.setTimelined(spriteTag);
+ }
+
+ ShowFrameTag showFrame = new ShowFrameTag(swf);
+ spriteTag.addTag(showFrame);
+ showFrame.setTimelined(spriteTag);
+ lastGifFrame = gifFrame;
+ swfFrame++;
+ float swfFrameTimeMs = swfFrame * 100 / swfFrameRate;
+ while (gifFrame < gifFrameCount && gifFrameTimeMs + gif.getDelay(gifFrame) < swfFrameTimeMs) {
+ gifFrameTimeMs += gif.getDelay(gifFrame);
+ gifFrame++;
+ }
+ }
+ spriteTag.frameCount = frameCount;
+ spriteTag.hasEndTag = true;
+ spriteTag.resetTimeline();
+ swf.resetTimeline();
+
+ return true;
+ }
+}
diff --git a/libsrc/gifreader/LICENSE.txt b/libsrc/gifreader/LICENSE.txt
new file mode 100644
index 000000000..e06d20818
--- /dev/null
+++ b/libsrc/gifreader/LICENSE.txt
@@ -0,0 +1,202 @@
+Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
diff --git a/libsrc/gifreader/build.xml b/libsrc/gifreader/build.xml
new file mode 100644
index 000000000..1f07e6cc6
--- /dev/null
+++ b/libsrc/gifreader/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project gifreader.
+
+
+
diff --git a/libsrc/gifreader/manifest.mf b/libsrc/gifreader/manifest.mf
new file mode 100644
index 000000000..328e8e5bc
--- /dev/null
+++ b/libsrc/gifreader/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/libsrc/gifreader/nbproject/build-impl.xml b/libsrc/gifreader/nbproject/build-impl.xml
new file mode 100644
index 000000000..9d23da367
--- /dev/null
+++ b/libsrc/gifreader/nbproject/build-impl.xml
@@ -0,0 +1,1756 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/libsrc/gifreader/nbproject/genfiles.properties b/libsrc/gifreader/nbproject/genfiles.properties
new file mode 100644
index 000000000..d659fb157
--- /dev/null
+++ b/libsrc/gifreader/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=4b83e956
+build.xml.script.CRC32=4ff4d15f
+build.xml.stylesheet.CRC32=f85dc8f2@1.95.0.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=4b83e956
+nbproject/build-impl.xml.script.CRC32=7c53165f
+nbproject/build-impl.xml.stylesheet.CRC32=f89f7d21@1.95.0.48
diff --git a/libsrc/gifreader/nbproject/project.properties b/libsrc/gifreader/nbproject/project.properties
new file mode 100644
index 000000000..4dcec5ffc
--- /dev/null
+++ b/libsrc/gifreader/nbproject/project.properties
@@ -0,0 +1,95 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processor.options=
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.modulepath=\
+ ${run.modulepath}
+debug.test.classpath=\
+ ${run.test.classpath}
+debug.test.modulepath=\
+ ${run.test.modulepath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/gifreader.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+dist.jlink.dir=${dist.dir}/jlink
+dist.jlink.output=${dist.jlink.dir}/gifreader
+excludes=
+file.reference.gifreader-src=src
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.modulepath=
+javac.processormodulepath=
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=17
+javac.target=17
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.modulepath=\
+ ${javac.modulepath}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.html5=false
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+# The jlink additional root modules to resolve
+jlink.additionalmodules=
+# The jlink additional command line parameters
+jlink.additionalparam=
+jlink.launcher=true
+jlink.launcher.name=gifreader
+main.class=
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=default_platform
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=
+run.modulepath=\
+ ${javac.modulepath}
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+run.test.modulepath=\
+ ${javac.test.modulepath}
+source.encoding=UTF-8
+src.dir=${file.reference.gifreader-src}
diff --git a/libsrc/gifreader/nbproject/project.xml b/libsrc/gifreader/nbproject/project.xml
new file mode 100644
index 000000000..426bdb779
--- /dev/null
+++ b/libsrc/gifreader/nbproject/project.xml
@@ -0,0 +1,13 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ gifreader
+
+
+
+
+
+
+
diff --git a/libsrc/gifreader/src/at/dhyan/open_imaging/GifDecoder.java b/libsrc/gifreader/src/at/dhyan/open_imaging/GifDecoder.java
new file mode 100644
index 000000000..5519089a8
--- /dev/null
+++ b/libsrc/gifreader/src/at/dhyan/open_imaging/GifDecoder.java
@@ -0,0 +1,671 @@
+package at.dhyan.open_imaging;
+
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.awt.image.DataBufferInt;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import static java.lang.System.arraycopy;
+
+/*
+ * Copyright 2014 Dhyan Blum
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *
+ * A decoder capable of processing a GIF data stream to render the graphics
+ * contained in it. This implementation follows the official
+ * GIF
+ * specification.
+ *
+ *
+ *
+ * Example usage:
+ *
+ *
+ *
+ *
+ *
+ * final GifImage gifImage = GifDecoder.read(int[] data);
+ * final int width = gifImage.getWidth();
+ * final int height = gifImage.getHeight();
+ * final int frameCount = gifImage.getFrameCount();
+ * for (int i = 0; i < frameCount; i++) {
+ * final BufferedImage image = gifImage.getFrame(i);
+ * final int delay = gif.getDelay(i);
+ * }
+ *
+ *
+ *
+ *
+ * @author Dhyan Blum
+ * @version 1.09 November 2017
+ */
+public final class GifDecoder {
+ static final class BitReader {
+ private int nextBitToRead;
+ private int numberOfBitsToRead;
+ private int bitMask; // Used to kill unwanted higher bits
+ private byte[] bytes; // Data array
+
+ // To avoid costly bounds checks, 'in' needs 2 more 0-bytes at the end
+ private void init(final byte[] bytes) {
+ this.bytes = bytes;
+ nextBitToRead = 0;
+ }
+
+ private int read() {
+ // Byte indices: (bitPos / 8), (bitPos / 8) + 1, (bitPos / 8) + 2
+ int byteIndex = nextBitToRead >>> 3; // Byte = bit / 8
+ int bitsToShiftRight = nextBitToRead & 7; // & 7 is the same as MODULO 8
+ int byte0, byte1, byte2;
+ byte0 = bytes[byteIndex++] & 0xFF; // & 0xFF gives us the unsigned values
+ byte1 = bytes[byteIndex++] & 0xFF;
+ byte2 = bytes[byteIndex] & 0xFF;
+ // Glue the bytes together, don't do more shifting than necessary
+ int buffer = ((byte2 << 8 | byte1) << 8 | byte0) >>> bitsToShiftRight;
+ nextBitToRead += numberOfBitsToRead;
+ return buffer & bitMask; // Kill the unwanted higher bits
+ }
+
+ private void setNumberOfBitsToRead(final int numberOfBitsToRead) {
+ this.numberOfBitsToRead = numberOfBitsToRead;
+ bitMask = (1 << numberOfBitsToRead) - 1;
+ }
+ }
+
+ static final class CodeTable {
+ private final int[][] table; // Maps codes to lists of colors
+ private int initTableSize; // Number of colors +2 for CLEAR + EOI
+ private int initCodeSize; // Initial code size
+ private int initCodeLimit; // First code limit
+ private int codeSize; // Current code size, maximum is 12 bits
+ private int nextCode; // Next available code for a new entry
+ private int nextCodeLimit; // Increase codeSize when nextCode == limit
+ private BitReader bitReader; // Notify when code sizes increases
+
+ public CodeTable() {
+ table = new int[4096][1];
+ }
+
+ private int add(final int[] indices) {
+ if (nextCode < 4096) {
+ if (nextCode == nextCodeLimit && codeSize < 12) {
+ codeSize++; // Max code size is 12
+ bitReader.setNumberOfBitsToRead(codeSize);
+ nextCodeLimit = (1 << codeSize) - 1; // 2^codeSize - 1
+ }
+ table[nextCode++] = indices;
+ }
+ return codeSize;
+ }
+
+ private int clear() {
+ codeSize = initCodeSize;
+ bitReader.setNumberOfBitsToRead(codeSize);
+ nextCodeLimit = initCodeLimit;
+ nextCode = initTableSize; // Don't recreate table, reset pointer
+ return codeSize;
+ }
+
+ private void init(final GifFrame fr, final int[] activeColTbl, final BitReader br) {
+ this.bitReader = br;
+ final int numColors = activeColTbl.length;
+ initCodeSize = fr.firstCodeSize;
+ initCodeLimit = (1 << initCodeSize) - 1; // 2^initCodeSize - 1
+ initTableSize = fr.endOfInfoCode + 1;
+ nextCode = initTableSize;
+ for (int c = numColors - 1; c >= 0; c--) {
+ table[c][0] = activeColTbl[c]; // Translated color
+ } // A gap may follow with no colors assigned if numCols < CLEAR
+ table[fr.clearCode] = new int[]{fr.clearCode}; // CLEAR
+ table[fr.endOfInfoCode] = new int[]{fr.endOfInfoCode}; // EOI
+ // Locate transparent color in code table and set to 0
+ if (fr.transpColFlag && fr.transpColIndex < numColors) {
+ table[fr.transpColIndex][0] = 0;
+ }
+ }
+ }
+
+ final class GifFrame {
+ // Graphic control extension (optional)
+ // Disposal: 0=NO_ACTION, 1=NO_DISPOSAL, 2=RESTORE_BG, 3=RESTORE_PREV
+ private int disposalMethod; // 0-3 as above, 4-7 undefined
+ private boolean transpColFlag; // 1 Bit
+ private int delay; // Unsigned, LSByte first, n * 1/100 * s
+ private int transpColIndex; // 1 Byte
+ // Image descriptor
+ private int x; // Position on the canvas from the left
+ private int y; // Position on the canvas from the top
+ private int w; // May be smaller than the base image
+ private int h; // May be smaller than the base image
+ private int wh; // width * height
+ private boolean hasLocColTbl; // Has local color table? 1 Bit
+ private boolean interlaceFlag; // Is an interlace image? 1 Bit
+ @SuppressWarnings("unused")
+ private boolean sortFlag; // True if local colors are sorted, 1 Bit
+ private int sizeOfLocColTbl; // Size of the local color table, 3 Bits
+ private int[] localColTbl; // Local color table (optional)
+ // Image data
+ private int firstCodeSize; // LZW minimum code size + 1 for CLEAR & EOI
+ private int clearCode;
+ private int endOfInfoCode;
+ private byte[] data; // Holds LZW encoded data
+ private BufferedImage img; // Full drawn image, not just the frame area
+ }
+
+ public final class GifImage {
+ public String header; // Bytes 0-5, GIF87a or GIF89a
+ private int w; // Unsigned 16 Bit, the least significant byte first
+ private int h; // Unsigned 16 Bit, the least significant byte first
+ private int wh; // Image width * image height
+ public boolean hasGlobColTbl; // 1 Bit
+ public int colorResolution; // 3 Bits
+ public boolean sortFlag; // True if global colors are sorted, 1 Bit
+ public int sizeOfGlobColTbl; // 2^(val(3 Bits) + 1), see spec
+ public int bgColIndex; // Background color index, 1 Byte
+ public int pxAspectRatio; // Pixel aspect ratio, 1 Byte
+ public int[] globalColTbl; // Global color table
+ private final List frames = new ArrayList(64);
+ public String appId = ""; // 8 Bytes at in[i+3], usually "NETSCAPE"
+ public String appAuthCode = ""; // 3 Bytes at in[i+11], usually "2.0"
+ public int repetitions = 0; // 0: infinite loop, N: number of loops
+ private BufferedImage img = null; // Currently, drawn frame
+ private final BitReader bits = new BitReader();
+ private final CodeTable codes = new CodeTable();
+ private Graphics2D g;
+
+ private int[] decode(final GifFrame fr, final int[] activeColTbl) {
+ codes.init(fr, activeColTbl, bits);
+ bits.init(fr.data); // Incoming codes
+ final int clearCode = fr.clearCode, endCode = fr.endOfInfoCode;
+ final int[] out = new int[wh]; // Target image pixel array
+ final int[][] tbl = codes.table; // Code table
+ int outPos = 0; // Next pixel position in the output image array
+ codes.clear(); // Init code table
+ bits.read(); // Skip leading clear code
+ int code = bits.read(); // Read first code
+ int[] pixels = tbl[code]; // Output pixel for first code
+ arraycopy(pixels, 0, out, outPos, pixels.length);
+ outPos += pixels.length;
+ try {
+ while (true) {
+ final int prevCode = code;
+ code = bits.read(); // Get next code in stream
+ if (code == clearCode) { // After a CLEAR table, there is
+ codes.clear(); // no previous code, we need to read
+ code = bits.read(); // a new one
+ pixels = tbl[code]; // Output pixels
+ arraycopy(pixels, 0, out, outPos, pixels.length);
+ outPos += pixels.length;
+ continue; // Back to the loop with a valid previous code
+ } else if (code == endCode) {
+ break;
+ }
+ final int[] prevVals = tbl[prevCode];
+ final int[] prevValsAndK = new int[prevVals.length + 1];
+ arraycopy(prevVals, 0, prevValsAndK, 0, prevVals.length);
+ if (code < codes.nextCode) { // Code table contains code
+ pixels = tbl[code]; // Output pixels
+ arraycopy(pixels, 0, out, outPos, pixels.length);
+ outPos += pixels.length;
+ prevValsAndK[prevVals.length] = tbl[code][0]; // K
+ } else {
+ prevValsAndK[prevVals.length] = prevVals[0]; // K
+ arraycopy(prevValsAndK, 0, out, outPos, prevValsAndK.length);
+ outPos += prevValsAndK.length;
+ }
+ codes.add(prevValsAndK); // Previous indices + K
+ }
+ } catch (final ArrayIndexOutOfBoundsException ignored) {
+ }
+ return out;
+ }
+
+ private int[] deinterlace(final int[] src, final GifFrame fr) {
+ final int w = fr.w, h = fr.h, wh = fr.wh;
+ final int[] dest = new int[src.length];
+ // Interlaced images are organized in 4 sets of pixel lines
+ final int set2Y = (h + 7) >>> 3; // Line no. = ceil(h/8.0)
+ final int set3Y = set2Y + ((h + 3) >>> 3); // ceil(h-4/8.0)
+ final int set4Y = set3Y + ((h + 1) >>> 2); // ceil(h-2/4.0)
+ // Sets' start indices in source array
+ final int set2 = w * set2Y, set3 = w * set3Y, set4 = w * set4Y;
+ // Line skips in destination array
+ final int w2 = w << 1, w4 = w2 << 1, w8 = w4 << 1;
+ // Group 1 contains every 8th line starting from 0
+ int from = 0, to = 0;
+ for (; from < set2; from += w, to += w8) {
+ arraycopy(src, from, dest, to, w);
+ } // Group 2 contains every 8th line starting from 4
+ for (to = w4; from < set3; from += w, to += w8) {
+ arraycopy(src, from, dest, to, w);
+ } // Group 3 contains every 4th line starting from 2
+ for (to = w2; from < set4; from += w, to += w4) {
+ arraycopy(src, from, dest, to, w);
+ } // Group 4 contains every 2nd line starting from 1 (biggest group)
+ for (to = w; from < wh; from += w, to += w2) {
+ arraycopy(src, from, dest, to, w);
+ }
+ return dest; // All pixel lines have now been rearranged
+ }
+
+ private void drawFrame(final GifFrame fr) {
+ // Determine the color table that will be active for this frame
+ final int[] activeColTbl = fr.hasLocColTbl ? fr.localColTbl : globalColTbl;
+ // Get pixels from data stream
+ int[] pixels = decode(fr, activeColTbl);
+ if (fr.interlaceFlag) {
+ pixels = deinterlace(pixels, fr); // Rearrange pixel lines
+ }
+ // Create image of type 2=ARGB for frame area
+ final BufferedImage frame = new BufferedImage(fr.w, fr.h, 2);
+ arraycopy(pixels, 0, ((DataBufferInt) frame.getRaster().getDataBuffer()).getData(), 0, fr.wh);
+ // Draw frame area on top of working image
+ g.drawImage(frame, fr.x, fr.y, null);
+
+ // Visualize frame boundaries during testing
+ // if (DEBUG_MODE) {
+ // if (prev != null) {
+ // g.setColor(Color.RED); // Previous frame color
+ // g.drawRect(prev.x, prev.y, prev.w - 1, prev.h - 1);
+ // }
+ // g.setColor(Color.GREEN); // New frame color
+ // g.drawRect(fr.x, fr.y, fr.w - 1, fr.h - 1);
+ // }
+
+ // Keep a copy of the previous frame's pixels in case we need to restore the frame
+ int[] prevPx = new int[wh];
+ arraycopy(((DataBufferInt) img.getRaster().getDataBuffer()).getData(), 0, prevPx, 0, wh);
+
+ // Create another copy for the end user to not expose internal state
+ fr.img = new BufferedImage(w, h, 2); // 2 = ARGB
+ arraycopy(prevPx, 0, ((DataBufferInt) fr.img.getRaster().getDataBuffer()).getData(), 0, wh);
+
+ // Handle disposal of current frame
+ if (fr.disposalMethod == 2) {
+ // Restore to background color (clear frame area only)
+ g.clearRect(fr.x, fr.y, fr.w, fr.h);
+ } else if (fr.disposalMethod == 3) {
+ // Restore previous frame
+ arraycopy(prevPx, 0, ((DataBufferInt) img.getRaster().getDataBuffer()).getData(), 0, wh);
+ }
+ }
+
+ /**
+ * Returns the background color of the first frame in this GIF image. If
+ * the frame has a local color table, the returned color will be from
+ * that table. If not, the color will be from the global color table.
+ * Returns 0 if there is neither a local nor a global color table.
+ *
+ * @return 32 bit ARGB color in the form 0xAARRGGBB
+ */
+ public final int getBackgroundColor() {
+ final GifFrame frame = frames.get(0);
+ if (frame.hasLocColTbl) {
+ return frame.localColTbl[bgColIndex];
+ } else if (hasGlobColTbl) {
+ return globalColTbl[bgColIndex];
+ }
+ return 0;
+ }
+
+ /**
+ * If not 0, the delay specifies how many hundredths (1/100) of a second
+ * to wait before displaying the frame after the current frame.
+ *
+ * @param index Index of the current frame, 0 to N-1
+ * @return Delay as number of hundredths (1/100) of a second
+ */
+ public final int getDelay(final int index) {
+ return frames.get(index).delay;
+ }
+
+ /**
+ * @param index Index of the frame to return as image, starting from 0.
+ * For incremental calls such as [0, 1, 2, ...] the method's
+ * run time is O(1) as only one frame is drawn per call. For
+ * random access calls such as [7, 12, ...] the run time is
+ * O(N+1) with N being the number of previous frames that
+ * need to be drawn before N+1 can be drawn on top. Once a
+ * frame has been drawn it is being cached and the run time
+ * is more or less O(0) to retrieve it from the list.
+ * @return A BufferedImage for the specified frame.
+ */
+ public BufferedImage getFrame(final int index) {
+ if (img == null) { // Init
+ img = new BufferedImage(w, h, 2); // 2 = ARGB
+ g = img.createGraphics();
+ g.setBackground(new Color(0, true)); // Transparent color
+ }
+ GifFrame fr = frames.get(index);
+ if (fr.img == null) {
+ // Draw all frames until and including the requested frame
+ for (int i = 0; i <= index; i++) {
+ fr = frames.get(i);
+ if (fr.img == null) {
+ drawFrame(fr);
+ }
+ }
+ }
+ return fr.img;
+ }
+
+ /**
+ * @return The number of frames contained in this GIF image
+ */
+ public final int getFrameCount() {
+ return frames.size();
+ }
+
+ /**
+ * @return The height of the GIF image
+ */
+ public final int getHeight() {
+ return h;
+ }
+
+ /**
+ * @return The width of the GIF image
+ */
+ public final int getWidth() {
+ return w;
+ }
+ }
+
+ static final boolean DEBUG_MODE = false;
+
+ /**
+ * @param in Raw image data as a byte[] array
+ * @return A GifImage object exposing the properties of the GIF image.
+ * @throws IOException If the image violates the GIF specification or is truncated.
+ */
+ public static GifImage read(final byte[] in) throws IOException {
+ final GifDecoder decoder = new GifDecoder();
+ final GifImage img = decoder.new GifImage();
+ GifFrame frame = null; // Currently open frame
+ int pos = readHeader(in, img); // Read header, get next byte position
+ pos = readLogicalScreenDescriptor(img, in, pos);
+ if (img.hasGlobColTbl) {
+ img.globalColTbl = new int[img.sizeOfGlobColTbl];
+ pos = readColTbl(in, img.globalColTbl, pos);
+ }
+ while (pos < in.length) {
+ final int block = in[pos] & 0xFF;
+ switch (block) {
+ case 0x21: // Extension introducer
+ if (pos + 1 >= in.length) {
+ throw new IOException("Unexpected end of file.");
+ }
+ switch (in[pos + 1] & 0xFF) {
+ case 0xFE: // Comment extension
+ pos = readTextExtension(in, pos);
+ break;
+ case 0xFF: // Application extension
+ pos = readAppExt(img, in, pos);
+ break;
+ case 0x01: // Plain text extension
+ frame = null; // End of current frame
+ pos = readTextExtension(in, pos);
+ break;
+ case 0xF9: // Graphic control extension
+ if (frame == null) {
+ frame = decoder.new GifFrame();
+ img.frames.add(frame);
+ }
+ pos = readGraphicControlExt(frame, in, pos);
+ break;
+ default:
+ throw new IOException("Unknown extension at " + pos);
+ }
+ break;
+ case 0x2C: // Image descriptor
+ if (frame == null) {
+ frame = decoder.new GifFrame();
+ img.frames.add(frame);
+ }
+ pos = readImgDescr(frame, in, pos);
+ if (frame.hasLocColTbl) {
+ frame.localColTbl = new int[frame.sizeOfLocColTbl];
+ pos = readColTbl(in, frame.localColTbl, pos);
+ }
+ pos = readImgData(frame, in, pos);
+ frame = null; // End of current frame
+ break;
+ case 0x3B: // GIF Trailer
+ return img; // Found trailer, finished reading.
+ default:
+ // Unknown block. The image is corrupted. Strategies: a) Skip
+ // and wait for a valid block. Experience: It'll get worse. b)
+ // Throw exception. c) Return gracefully if we are almost done
+ // processing. The frames we have so far should be error-free.
+ final double progress = 1.0 * pos / in.length;
+ if (progress < 0.9) {
+ throw new IOException("Unknown block at: " + pos);
+ }
+ pos = in.length; // Exit loop
+ }
+ }
+ return img;
+ }
+
+ /**
+ * @param is Image data as input stream. This method will read from the
+ * input stream's current position. It will not reset the
+ * position before reading and won't reset or close the stream
+ * afterwards. Call these methods before and after calling this
+ * method as needed.
+ * @return A GifImage object exposing the properties of the GIF image.
+ * @throws IOException If an I/O error occurs, the image violates the GIF
+ * specification or the GIF is truncated.
+ */
+ public static GifImage read(final InputStream is) throws IOException {
+ final byte[] data = new byte[is.available()];
+ is.read(data, 0, data.length);
+ return read(data);
+ }
+
+ /**
+ * @param img GIF image
+ * @param in Raw data
+ * @param i Index of the first byte of the application extension
+ * @return Index of the first byte after this extension
+ */
+ static int readAppExt(final GifImage img, final byte[] in, int i) {
+ img.appId = new String(in, i + 3, 8); // should be "NETSCAPE"
+ img.appAuthCode = new String(in, i + 11, 3); // should be "2.0"
+ i += 14; // Go to sub-block size, it's value should be 3
+ final int subBlockSize = in[i] & 0xFF;
+ // The only app extension widely used is NETSCAPE, it's got 3 data bytes
+ if (subBlockSize == 3) {
+ // in[i+1] should have value 01, in[i+5] should be block terminator
+ img.repetitions = in[i + 2] & 0xFF | in[i + 3] & 0xFF << 8; // Short
+ return i + 5;
+ } // Skip unknown application extensions
+ while ((in[i] & 0xFF) != 0) { // While sub-block size != 0
+ i += (in[i] & 0xFF) + 1; // Skip to next sub-block
+ }
+ return i + 1;
+ }
+
+ /**
+ * @param in Raw data
+ * @param colors Pre-initialized target array to store ARGB colors
+ * @param i Index of the color table's first byte
+ * @return Index of the first byte after the color table
+ */
+ static int readColTbl(final byte[] in, final int[] colors, int i) {
+ final int numColors = colors.length;
+ for (int c = 0; c < numColors; c++) {
+ final int a = 0xFF; // Alpha 255 (opaque)
+ final int r = in[i++] & 0xFF; // 1st byte is red
+ final int g = in[i++] & 0xFF; // 2nd byte is green
+ final int b = in[i++] & 0xFF; // 3rd byte is blue
+ colors[c] = ((a << 8 | r) << 8 | g) << 8 | b;
+ }
+ return i;
+ }
+
+ /**
+ * @param fr GIF frame
+ * @param in Raw data
+ * @param i Index of the extension introducer
+ * @return Index of the first byte after this block
+ */
+ static int readGraphicControlExt(final GifFrame fr, final byte[] in, final int i) {
+ fr.disposalMethod = (in[i + 3] & 0b00011100) >>> 2; // Bits 4-2
+ fr.transpColFlag = (in[i + 3] & 1) == 1; // Bit 0
+ fr.delay = in[i + 4] & 0xFF | (in[i + 5] & 0xFF) << 8; // 16 bit LSB
+ fr.transpColIndex = in[i + 6] & 0xFF; // Byte 6
+ return i + 8; // Skipped byte 7 (blockTerminator), as it's always 0x00
+ }
+
+ /**
+ * @param in Raw data
+ * @param img The GifImage object that is currently read
+ * @return Index of the first byte after this block
+ * @throws IOException If the GIF header/trailer is missing, incomplete or unknown
+ */
+ static int readHeader(final byte[] in, final GifImage img) throws IOException {
+ if (in.length < 6) { // Check first 6 bytes
+ throw new IOException("Image is truncated.");
+ }
+ img.header = new String(in, 0, 6);
+ if (!img.header.equals("GIF87a") && !img.header.equals("GIF89a")) {
+ throw new IOException("Invalid GIF header.");
+ }
+ return 6;
+ }
+
+ /**
+ * @param fr The GIF frame to whom this image descriptor belongs
+ * @param in Raw data
+ * @param i Index of the first byte of this block, i.e. the minCodeSize
+ * @return Byte index
+ */
+ static int readImgData(final GifFrame fr, final byte[] in, int i) {
+ final int fileSize = in.length;
+ final int minCodeSize = in[i++] & 0xFF; // Read code size, go to block
+ final int clearCode = 1 << minCodeSize; // CLEAR = 2^minCodeSize
+ fr.firstCodeSize = minCodeSize + 1; // Add 1 bit for CLEAR and EOI
+ fr.clearCode = clearCode;
+ fr.endOfInfoCode = clearCode + 1;
+ final int imgDataSize = readImgDataSize(in, i);
+ final byte[] imgData = new byte[imgDataSize + 2];
+ int imgDataPos = 0;
+ int subBlockSize = in[i] & 0xFF;
+ while (subBlockSize > 0) { // While block has data
+ try { // Next line may throw exception if sub-block size is fake
+ final int nextSubBlockSizePos = i + subBlockSize + 1;
+ final int nextSubBlockSize = in[nextSubBlockSizePos] & 0xFF;
+ arraycopy(in, i + 1, imgData, imgDataPos, subBlockSize);
+ imgDataPos += subBlockSize; // Move output data position
+ i = nextSubBlockSizePos; // Move to next sub-block size
+ subBlockSize = nextSubBlockSize;
+ } catch (final Exception e) {
+ // Sub-block exceeds file end, only use remaining bytes
+ subBlockSize = fileSize - i - 1; // Remaining bytes
+ arraycopy(in, i + 1, imgData, imgDataPos, subBlockSize);
+ imgDataPos += subBlockSize; // Move output data position
+ i += subBlockSize + 1; // Move to next sub-block size
+ break;
+ }
+ }
+ fr.data = imgData; // Holds LZW encoded data
+ i++; // Skip last sub-block size, should be 0
+ return i;
+ }
+
+ static int readImgDataSize(final byte[] in, int i) {
+ final int fileSize = in.length;
+ int imgDataPos = 0;
+ int subBlockSize = in[i] & 0xFF;
+ while (subBlockSize > 0) { // While block has data
+ try { // Next line may throw exception if sub-block size is fake
+ final int nextSubBlockSizePos = i + subBlockSize + 1;
+ final int nextSubBlockSize = in[nextSubBlockSizePos] & 0xFF;
+ imgDataPos += subBlockSize; // Move output data position
+ i = nextSubBlockSizePos; // Move to next sub-block size
+ subBlockSize = nextSubBlockSize;
+ } catch (final Exception e) {
+ // Sub-block exceeds file end, only use remaining bytes
+ subBlockSize = fileSize - i - 1; // Remaining bytes
+ imgDataPos += subBlockSize; // Move output data position
+ break;
+ }
+ }
+ return imgDataPos;
+ }
+
+ /**
+ * @param fr The GIF frame to whom this image descriptor belongs
+ * @param in Raw data
+ * @param i Index of the image separator, i.e. the first block byte
+ * @return Index of the first byte after this block
+ */
+ static int readImgDescr(final GifFrame fr, final byte[] in, int i) {
+ fr.x = in[++i] & 0xFF | (in[++i] & 0xFF) << 8; // Byte 1-2: left
+ fr.y = in[++i] & 0xFF | (in[++i] & 0xFF) << 8; // Byte 3-4: top
+ fr.w = in[++i] & 0xFF | (in[++i] & 0xFF) << 8; // Byte 5-6: width
+ fr.h = in[++i] & 0xFF | (in[++i] & 0xFF) << 8; // Byte 7-8: height
+ fr.wh = fr.w * fr.h;
+ final byte b = in[++i]; // Byte 9 is a packed byte
+ fr.hasLocColTbl = (b & 0b10000000) >>> 7 == 1; // Bit 7
+ fr.interlaceFlag = (b & 0b01000000) >>> 6 == 1; // Bit 6
+ fr.sortFlag = (b & 0b00100000) >>> 5 == 1; // Bit 5
+ final int colTblSizePower = (b & 7) + 1; // Bits 2-0
+ fr.sizeOfLocColTbl = 1 << colTblSizePower; // 2^(N+1), As per the spec
+ return ++i;
+ }
+
+ /**
+ * @param img GIF image
+ * @param i Start index of this block.
+ * @return Index of the first byte after this block.
+ */
+ static int readLogicalScreenDescriptor(final GifImage img, final byte[] in, final int i) {
+ img.w = in[i] & 0xFF | (in[i + 1] & 0xFF) << 8; // 16 bit, LSB 1st
+ img.h = in[i + 2] & 0xFF | (in[i + 3] & 0xFF) << 8; // 16 bit
+ img.wh = img.w * img.h;
+ final byte b = in[i + 4]; // Byte 4 is a packed byte
+ img.hasGlobColTbl = (b & 0b10000000) >>> 7 == 1; // Bit 7
+ final int colResPower = ((b & 0b01110000) >>> 4) + 1; // Bits 6-4
+ img.colorResolution = 1 << colResPower; // 2^(N+1), As per the spec
+ img.sortFlag = (b & 0b00001000) >>> 3 == 1; // Bit 3
+ final int globColTblSizePower = (b & 7) + 1; // Bits 0-2
+ img.sizeOfGlobColTbl = 1 << globColTblSizePower; // 2^(N+1), see spec
+ img.bgColIndex = in[i + 5] & 0xFF; // 1 Byte
+ img.pxAspectRatio = in[i + 6] & 0xFF; // 1 Byte
+ return i + 7;
+ }
+
+ /**
+ * @param in Raw data
+ * @param pos Index of the extension introducer
+ * @return Index of the first byte after this block
+ */
+ static int readTextExtension(final byte[] in, final int pos) {
+ int i = pos + 2; // Skip extension introducer and label
+ int subBlockSize = in[i++] & 0xFF;
+ while (subBlockSize != 0 && i < in.length) {
+ i += subBlockSize;
+ subBlockSize = in[i++] & 0xFF;
+ }
+ return i;
+ }
+}
diff --git a/nbproject/project.xml b/nbproject/project.xml
index 45c328f1d..9b5203989 100644
--- a/nbproject/project.xml
+++ b/nbproject/project.xml
@@ -323,7 +323,7 @@
src
- lib/jpproxy.jar;lib/trident-6.2.jar;lib/substance-flamingo-6.2.jar;lib/flamingo-6.2.jar;lib/substance-6.2.jar;libsrc/ffdec_lib/src;lib/tablelayout.jar;lib/jsyntaxpane-0.9.5.jar;lib/JavactiveX.jar;lib/flashdebugger.jar;lib/treetable.jar;lib/minimal-json-0.9.5.jar;libsrc/ffdec_lib/lib/gnujpdf.jar;libsrc/ffdec_lib/lib/jna-3.5.1.jar;libsrc/ffdec_lib/lib/jna-platform-3.5.1.jar;libsrc/ffdec_lib/lib/flashdebugger.jar
+ lib/jpproxy.jar;lib/trident-6.2.jar;lib/substance-flamingo-6.2.jar;lib/flamingo-6.2.jar;lib/substance-6.2.jar;libsrc/ffdec_lib/src;lib/tablelayout.jar;lib/jsyntaxpane-0.9.5.jar;lib/JavactiveX.jar;lib/flashdebugger.jar;lib/treetable.jar;lib/minimal-json-0.9.5.jar;libsrc/ffdec_lib/lib/gnujpdf.jar;libsrc/ffdec_lib/lib/jna-3.5.1.jar;libsrc/ffdec_lib/lib/jna-platform-3.5.1.jar;libsrc/ffdec_lib/lib/flashdebugger.jar;lib/gifreader.jar
build
javadoc
reports
diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java
index d08f4aeb5..cc61afadc 100644
--- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java
+++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java
@@ -131,6 +131,7 @@ import com.jpexs.decompiler.flash.importers.MovieImporter;
import com.jpexs.decompiler.flash.importers.ScriptImporterProgressListener;
import com.jpexs.decompiler.flash.importers.ShapeImporter;
import com.jpexs.decompiler.flash.importers.SoundImporter;
+import com.jpexs.decompiler.flash.importers.SpriteImporter;
import com.jpexs.decompiler.flash.importers.SwfXmlImporter;
import com.jpexs.decompiler.flash.importers.SymbolClassImporter;
import com.jpexs.decompiler.flash.importers.TextImporter;
@@ -4438,6 +4439,33 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
}
}
+ public void replaceWithGifButtonActionPerformed(TreeItem item) {
+ if (item == null) {
+ return;
+ }
+ if (item instanceof DefineSpriteTag) {
+ String filter = "filter.images|*.gif";
+ File selectedFile = showImportFileChooser(filter, false);
+ if (selectedFile != null) {
+ File selfile = Helper.fixDialogFile(selectedFile);
+ DefineSpriteTag sprite = (DefineSpriteTag)item;
+ SWF swf = sprite.getSwf();
+ try(FileInputStream fis = new FileInputStream(selfile)){
+ SpriteImporter spriteImporter = new SpriteImporter();
+ spriteImporter.importSprite((DefineSpriteTag)item, fis);
+
+ swf.clearImageCache();
+ swf.clearShapeCache();
+ } catch (IOException ex) {
+ logger.log(Level.SEVERE, "Invalid image", ex);
+ ViewMessages.showMessageDialog(this, translate("error.image.invalid"), translate("error"), JOptionPane.ERROR_MESSAGE);
+ }
+ reload(true);
+ refreshTree(swf);
+ }
+ }
+ }
+
public void replaceNoFillButtonActionPerformed(TreeItem item) {
if (item == null) {
return;
@@ -5058,10 +5086,10 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
previewPanel.showDisplayEditTagPanel((PlaceObjectTypeTag) treeItem, frame);
} else if (treeItem instanceof ShapeTag) {
previewPanel.showDisplayEditTagPanel((ShapeTag) treeItem, 0);
- previewPanel.setImageReplaceButtonVisible(false, false, !((Tag) treeItem).isReadOnly(), false, false, false);
+ previewPanel.setImageReplaceButtonVisible(false, false, !((Tag) treeItem).isReadOnly(), false, false, false, false);
} else if (treeItem instanceof MorphShapeTag) {
previewPanel.showDisplayEditTagPanel((MorphShapeTag) treeItem, 0);
- previewPanel.setImageReplaceButtonVisible(false, false, false, false, false, !((Tag) treeItem).isReadOnly());
+ previewPanel.setImageReplaceButtonVisible(false, false, false, false, false, !((Tag) treeItem).isReadOnly(), false);
} else if (treeItem instanceof MetadataTag) {
MetadataTag metadataTag = (MetadataTag) treeItem;
previewPanel.showMetaDataPanel(metadataTag);
@@ -5076,7 +5104,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
previewPanel.showUnknownPanel(unknownTag);
} else if (treeItem instanceof ImageTag) {
ImageTag imageTag = (ImageTag) treeItem;
- previewPanel.setImageReplaceButtonVisible(!((Tag) imageTag).isReadOnly() && imageTag.importSupported(), imageTag instanceof DefineBitsJPEG3Tag || imageTag instanceof DefineBitsJPEG4Tag, false, false, false, false);
+ previewPanel.setImageReplaceButtonVisible(!((Tag) imageTag).isReadOnly() && imageTag.importSupported(), imageTag instanceof DefineBitsJPEG3Tag || imageTag instanceof DefineBitsJPEG4Tag, false, false, false, false, false);
SWF imageSWF = makeTimelinedImage(imageTag);
previewPanel.showImagePanel(imageSWF, imageSWF, 0, false, true, true, true, true, false, false);
@@ -5092,10 +5120,13 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
previewPanel.setParametersPanelVisible(false);
if (treeItem instanceof ShapeTag) {
- previewPanel.setImageReplaceButtonVisible(false, false, !((Tag) treeItem).isReadOnly(), false, false, false);
+ previewPanel.setImageReplaceButtonVisible(false, false, !((Tag) treeItem).isReadOnly(), false, false, false, false);
}
if (treeItem instanceof DefineVideoStreamTag) {
- previewPanel.setImageReplaceButtonVisible(false, false, false, false, !((Tag) treeItem).isReadOnly(), false);
+ previewPanel.setImageReplaceButtonVisible(false, false, false, false, !((Tag) treeItem).isReadOnly(), false, false);
+ }
+ if (treeItem instanceof DefineSpriteTag) {
+ previewPanel.setImageReplaceButtonVisible(false, false, false, false, false, false, !((Tag) treeItem).isReadOnly());
}
previewPanel.showImagePanel(timelined, tag.getSwf(), -1, true, Configuration.autoPlayPreviews.get(), !Configuration.animateSubsprites.get(), treeItem instanceof ShapeTag, !Configuration.playFrameSounds.get(), (treeItem instanceof DefineSpriteTag) || (treeItem instanceof ButtonTag), (treeItem instanceof DefineSpriteTag) || (treeItem instanceof ButtonTag) || (treeItem instanceof ShapeTag));
} else if (treeItem instanceof Frame && internalViewer) {
@@ -5112,7 +5143,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
previewPanel.showImagePanel(timelinedContainer, swf, frame, true, Configuration.autoPlayPreviews.get(), !Configuration.animateSubsprites.get(), false, !Configuration.playFrameSounds.get(), true, false);
} else if ((treeItem instanceof SoundTag)) { //&& isInternalFlashViewerSelected() && (Arrays.asList("mp3", "wav").contains(((SoundTag) tagObj).getExportFormat())))) {
previewPanel.showImagePanel(new SerializableImage(View.loadImage("sound32")));
- previewPanel.setImageReplaceButtonVisible(false, false, false, !((Tag) treeItem).isReadOnly() && ((SoundTag) treeItem).importSupported(), false, false);
+ previewPanel.setImageReplaceButtonVisible(false, false, false, !((Tag) treeItem).isReadOnly() && ((SoundTag) treeItem).importSupported(), false, false, false);
try {
SoundTagPlayer soundThread = new SoundTagPlayer(null, (SoundTag) treeItem, Configuration.loopMedia.get() ? Integer.MAX_VALUE : 1, true);
if (!Configuration.autoPlaySounds.get()) {
@@ -5258,7 +5289,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
previewPanel.clear();
stopFlashPlayer();
- previewPanel.setImageReplaceButtonVisible(false, false, false, false, false, false);
+ previewPanel.setImageReplaceButtonVisible(false, false, false, false, false, false, false);
boolean internalViewer = !isAdobeFlashPlayerEnabled();
diff --git a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java
index cab2562c8..684184c8d 100644
--- a/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java
+++ b/src/com/jpexs/decompiler/flash/gui/PreviewPanel.java
@@ -199,6 +199,8 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
private JButton replaceImageButton;
private JButton replaceImageAlphaButton;
+
+ private JButton replaceSpriteButton;
private JButton replaceMovieButton;
@@ -395,6 +397,17 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
replaceImageAlphaButton.addActionListener(mainPanel::replaceAlphaButtonActionPerformed);
replaceImageAlphaButton.setVisible(false);
+
+ replaceSpriteButton = new JButton(mainPanel.translate("button.replaceWithGif"), View.getIcon("replacesprite16"));
+ replaceSpriteButton.setMargin(new Insets(3, 3, 3, 10));
+ replaceSpriteButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ mainPanel.replaceWithGifButtonActionPerformed(mainPanel.getCurrentTree().getCurrentTreeItem());
+ }
+ });
+ replaceSpriteButton.setVisible(false);
+
replaceMovieButton = new JButton(mainPanel.translate("button.replace"), View.getIcon("importmovie16"));
replaceMovieButton.setMargin(new Insets(3, 3, 3, 10));
replaceMovieButton.addActionListener(new ActionListener() {
@@ -421,6 +434,7 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
//imageButtonsPanel.add(replaceShapeUpdateBoundsButton);
imageButtonsPanel.add(replaceImageButton);
imageButtonsPanel.add(replaceImageAlphaButton);
+ imageButtonsPanel.add(replaceSpriteButton);
imageButtonsPanel.add(replaceMovieButton);
imageButtonsPanel.add(prevFontsButton);
imageButtonsPanel.add(nextFontsButton);
@@ -1692,16 +1706,18 @@ public class PreviewPanel extends JPersistentSplitPane implements TagEditorPanel
displayEditTransformButton.setVisible(!tag.isReadOnly() && !readOnly);
}
- public void setImageReplaceButtonVisible(boolean showImage, boolean showAlpha, boolean showShape, boolean showSound, boolean showMovie, boolean showMorphShape) {
+ public void setImageReplaceButtonVisible(boolean showImage, boolean showAlpha, boolean showShape, boolean showSound, boolean showMovie, boolean showMorphShape, boolean showSprite) {
if (readOnly) {
showImage = false;
showAlpha = false;
showShape = false;
showSound = false;
showMovie = false;
+ showSprite = false;
}
replaceImageButton.setVisible(showImage);
replaceImageAlphaButton.setVisible(showAlpha);
+ replaceSpriteButton.setVisible(showSprite);
replaceShapeButton.setVisible(showShape);
morphShowPanel.setVisible(showMorphShape);
displayEditEditPointsButton.setVisible(showShape || showMorphShape);
diff --git a/src/com/jpexs/decompiler/flash/gui/graphics/replacesprite16.png b/src/com/jpexs/decompiler/flash/gui/graphics/replacesprite16.png
new file mode 100644
index 000000000..5334fc159
Binary files /dev/null and b/src/com/jpexs/decompiler/flash/gui/graphics/replacesprite16.png differ
diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties
index de5bd83dd..2e36bd09b 100644
--- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties
+++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties
@@ -1161,3 +1161,5 @@ button.abcexploretrait = Show trait in ABC Explorer
#after 19.0.0
binarydata.swfInside.packer = It looks like there is SWF inside this binary data tag packed with %packer%. Click here to unpack the SWF and load it as subtree.
+
+button.replaceWithGif = Replace with GIF...
\ No newline at end of file
diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties
index a91af26af..7c907ff48 100644
--- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties
+++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame_cs.properties
@@ -1146,3 +1146,5 @@ button.abcexploretrait = Zobrazit vlastnost v pr\u016fzkumn\u00edku ABC
#after 19.0.0
binarydata.swfInside.packer = Vypad\u00e1 to, \u017ee uvnit\u0159 v tomto BinaryData tagu se nach\u00e1z\u00ed SWF soubor zabalen\u00fd pomoc\u00ed %packer%. Klikn\u011bte zde pro jeho rozbalen\u00ed a na\u010dten\u00ed jako podstrom.
+
+button.replaceWithGif = Nahradit GIFem...
diff --git a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java
index cf67cdbb7..1bfa94a39 100644
--- a/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java
+++ b/src/com/jpexs/decompiler/flash/gui/tagtree/TagTreeContextMenu.java
@@ -254,6 +254,8 @@ public class TagTreeContextMenu extends JPopupMenu {
private JMenuItem unpinOthersMenuItem;
private JMenuItem abcExplorerMenuItem;
+
+ private JMenuItem replaceWithGifMenuItem;
private List items = new ArrayList<>();
@@ -356,6 +358,16 @@ public class TagTreeContextMenu extends JPopupMenu {
replaceWithTagMenuItem.addActionListener(this::replaceWithTagActionPerformed);
replaceWithTagMenuItem.setIcon(View.getIcon("replacewithtag16"));
add(replaceWithTagMenuItem);
+
+ replaceWithGifMenuItem = new JMenuItem(mainPanel.translate("button.replaceWithGif"));
+ replaceWithGifMenuItem.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ mainPanel.replaceWithGifButtonActionPerformed(getCurrentItem());
+ }
+ });
+ replaceWithGifMenuItem.setIcon(View.getIcon("replacesprite16"));
+ add(replaceWithGifMenuItem);
replaceRefsWithTagMenuItem = new JMenuItem(mainPanel.translate("button.replaceRefs"));
replaceRefsWithTagMenuItem.addActionListener(this::replaceRefsWithTagActionPerformed);
@@ -938,6 +950,7 @@ public class TagTreeContextMenu extends JPopupMenu {
exportABCMenuItem.setVisible(false);
replaceMenuItem.setVisible(false);
replaceNoFillMenuItem.setVisible(false);
+ replaceWithGifMenuItem.setVisible(false);
replaceWithTagMenuItem.setVisible(false);
replaceRefsWithTagMenuItem.setVisible(false);
abcExplorerMenuItem.setVisible(false);
@@ -1024,7 +1037,7 @@ public class TagTreeContextMenu extends JPopupMenu {
replaceMenuItem.setVisible(true);
replaceNoFillMenuItem.setVisible(true);
}
-
+
if (canReplace.test(it -> it instanceof DefineBinaryDataTag)) {
replaceMenuItem.setVisible(true);
}
@@ -1097,6 +1110,10 @@ public class TagTreeContextMenu extends JPopupMenu {
replaceRefsWithTagMenuItem.setVisible(true);
}
}
+
+ if (firstItem instanceof DefineSpriteTag) {
+ replaceWithGifMenuItem.setVisible(true);
+ }
TreePath thisPath = tree.getFullModel().getTreePath(firstItem);
TreeItem parent = thisPath == null ? null : (TreeItem) thisPath.getParentPath().getLastPathComponent();