mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-23 16:05:31 +00:00
#1378 Transparent background on PNG/GIF sprite export,
SWF background on shape BMP export
This commit is contained in:
@@ -379,6 +379,7 @@ public class FrameExporter {
|
||||
}
|
||||
|
||||
final Color fbackgroundColor = backgroundColor;
|
||||
final boolean fusesTransparency = settings.mode == FrameExportMode.PNG || settings.mode == FrameExportMode.GIF;
|
||||
final Iterator<BufferedImage> frameImages = new Iterator<BufferedImage>() {
|
||||
private int pos = 0;
|
||||
|
||||
@@ -406,7 +407,7 @@ public class FrameExporter {
|
||||
}
|
||||
|
||||
int fframe = fframes.get(pos++);
|
||||
BufferedImage result = SWF.frameToImageGet(tim, fframe, fframe, null, 0, tim.displayRect, new Matrix(), null, null, settings.zoom).getBufferedImage();
|
||||
BufferedImage result = SWF.frameToImageGet(tim, fframe, fframe, null, 0, tim.displayRect, new Matrix(), null, fusesTransparency ? null : fbackgroundColor, settings.zoom).getBufferedImage();
|
||||
|
||||
if (evl != null) {
|
||||
evl.handleExportedEvent("frame", pos, fframes.size(), tagName);
|
||||
|
||||
@@ -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;
|
||||
@@ -35,11 +36,13 @@ import com.jpexs.decompiler.flash.tags.base.ShapeTag;
|
||||
import com.jpexs.decompiler.flash.tags.enums.ImageFormat;
|
||||
import com.jpexs.decompiler.flash.types.CXFORMWITHALPHA;
|
||||
import com.jpexs.decompiler.flash.types.RECT;
|
||||
import com.jpexs.decompiler.flash.types.RGB;
|
||||
import com.jpexs.decompiler.flash.types.SHAPE;
|
||||
import com.jpexs.helpers.Helper;
|
||||
import com.jpexs.helpers.Path;
|
||||
import com.jpexs.helpers.SerializableImage;
|
||||
import com.jpexs.helpers.utf8.Utf8Helper;
|
||||
import java.awt.Graphics2D;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
@@ -59,7 +62,7 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
public class ShapeExporter {
|
||||
|
||||
|
||||
public List<File> exportShapes(AbortRetryIgnoreHandler handler, final String outdir, final SWF swf, ReadOnlyTagList tags, final ShapeExportSettings settings, EventListener evl) throws IOException, InterruptedException {
|
||||
List<File> ret = new ArrayList<>();
|
||||
if (tags.isEmpty()) {
|
||||
return ret;
|
||||
@@ -109,6 +112,14 @@ public class ShapeExporter {
|
||||
int newHeight = (int) (rect.getHeight() * settings.zoom / SWF.unitDivisor) + 1;
|
||||
SerializableImage img = new SerializableImage(newWidth, newHeight, SerializableImage.TYPE_INT_ARGB_PRE);
|
||||
img.fillTransparent();
|
||||
if (settings.mode == ShapeExportMode.BMP) {
|
||||
RGB backColor = swf.getBackgroundColor().backgroundColor;
|
||||
if (backColor != null) {
|
||||
Graphics2D g = (Graphics2D) img.getGraphics();
|
||||
g.setColor(backColor.toColor());
|
||||
g.fillRect(0, 0, img.getWidth(), img.getHeight());
|
||||
}
|
||||
}
|
||||
Matrix m = Matrix.getScaleInstance(settings.zoom);
|
||||
m.translate(-rect.Xmin, -rect.Ymin);
|
||||
st.toImage(0, 0, 0, new RenderContext(), img, false, m, m, m, new CXFORMWITHALPHA());
|
||||
|
||||
@@ -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.importers.svg;
|
||||
|
||||
import com.jpexs.decompiler.flash.ReadOnlyTagList;
|
||||
@@ -1062,7 +1063,7 @@ public class SvgImporter {
|
||||
swf.assignExportNamesToSymbols();
|
||||
st.shapeBounds.Xmax = (int) (si.getWidth() * SWF.unitDivisor);
|
||||
st.shapeBounds.Ymax = (int) (si.getHeight() * SWF.unitDivisor);
|
||||
st.shapeBounds.Ymax = (int) (si.getHeight() * SWF.unitDivisor);
|
||||
new ShapeExporter().exportShapes(null, "./outex/", swf, new ReadOnlyTagList(li), new ShapeExportSettings(ShapeExportMode.SVG, 1), null);
|
||||
}
|
||||
|
||||
//Test for SVG
|
||||
|
||||
Reference in New Issue
Block a user