mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-19 16:42:03 +00:00
#1156 Canvas Export - 9 slice scaling (DefineScalingGrid)
This commit is contained in:
@@ -92,6 +92,7 @@ import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
|
||||
import com.jpexs.decompiler.flash.tags.ABCContainerTag;
|
||||
import com.jpexs.decompiler.flash.tags.DebugIDTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBinaryDataTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineScalingGridTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineSoundTag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineSpriteTag;
|
||||
import com.jpexs.decompiler.flash.tags.DoABC2Tag;
|
||||
@@ -1976,7 +1977,7 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
return "character";
|
||||
}
|
||||
|
||||
public static void writeLibrary(SWF fswf, Set<Integer> library, OutputStream fos) throws IOException {
|
||||
public static void libraryToHtmlCanvas(SWF fswf, Set<Integer> library, OutputStream fos) throws IOException {
|
||||
for (int c : library) {
|
||||
CharacterTag ch = fswf.getCharacter(c);
|
||||
if (ch instanceof FontTag) {
|
||||
@@ -2000,6 +2001,24 @@ public final class SWF implements SWFContainerItem, Timelined {
|
||||
fos.write(Utf8Helper.getBytes(sb.toString()));
|
||||
}
|
||||
fos.write(Utf8Helper.getBytes("}\r\n\r\n"));
|
||||
DefineScalingGridTag scalingGrid = ch.getScalingGridTag();
|
||||
if (scalingGrid != null && (ch instanceof BoundedTag)) {
|
||||
BoundedTag bt = (BoundedTag) ch;
|
||||
RECT bounds = bt.getRect();
|
||||
fos.write(Utf8Helper.getBytes("boundRects[\"" + (getTypePrefix(ch) + c) + "\"] = {"
|
||||
+ "xMin:" + bounds.Xmin + ","
|
||||
+ "xMax:" + bounds.Xmax + ","
|
||||
+ "yMin:" + bounds.Ymin + ","
|
||||
+ "yMax:" + bounds.Ymax
|
||||
+ "};\r\n\r\n"));
|
||||
RECT grid = scalingGrid.splitter;
|
||||
fos.write(Utf8Helper.getBytes("scalingGrids[\"" + (getTypePrefix(ch) + c) + "\"] = {"
|
||||
+ "xMin:" + grid.Xmin + ","
|
||||
+ "xMax:" + grid.Xmax + ","
|
||||
+ "yMin:" + grid.Ymin + ","
|
||||
+ "yMax:" + grid.Ymax
|
||||
+ "};\r\n\r\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,10 +264,11 @@ public class FrameExporter {
|
||||
int height = (int) (ftim.displayRect.getHeight() * settings.zoom / SWF.unitDivisor);
|
||||
try (final OutputStream fos = new BufferedOutputStream(new FileOutputStream(f))) {
|
||||
fos.write(Utf8Helper.getBytes("\r\n"));
|
||||
fos.write(Utf8Helper.getBytes("var scalingGrids = {};\r\nvar boundRects = {};\r\n"));
|
||||
Set<Integer> library = new HashSet<>();
|
||||
ftim.getNeededCharacters(fframes, library);
|
||||
|
||||
SWF.writeLibrary(fswf, library, fos);
|
||||
SWF.libraryToHtmlCanvas(fswf, library, fos);
|
||||
|
||||
String currentName = ftim.id == 0 ? "main" : SWF.getTypePrefix(fswf.getCharacter(ftim.id)) + ftim.id;
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
|
||||
import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler;
|
||||
@@ -113,7 +114,7 @@ public class MorphShapeExporter {
|
||||
needed.add(ct.getCharacterId());
|
||||
ct.getNeededCharactersDeep(needed);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWF.libraryToHtmlCanvas(ct.getSwf(), needed, baos);
|
||||
fos.write(Utf8Helper.getBytes(cse.getHtml(new String(baos.toByteArray(), Utf8Helper.charset), SWF.getTypePrefix(mst) + mst.getCharacterId(), mst.getRect())));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library.
|
||||
* License along with this library.
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.exporters;
|
||||
|
||||
import com.jpexs.decompiler.flash.AbortRetryIgnoreHandler;
|
||||
@@ -139,7 +140,7 @@ public class ShapeExporter {
|
||||
needed.add(st.getCharacterId());
|
||||
st.getNeededCharactersDeep(needed);
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
SWF.libraryToHtmlCanvas(st.getSwf(), needed, baos);
|
||||
fos.write(Utf8Helper.getBytes(cse.getHtml(new String(baos.toByteArray(), Utf8Helper.charset), SWF.getTypePrefix(st) + st.getCharacterId(), st.getRect())));
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user