mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 11:01:10 +00:00
Issue #83 - Fixed Zlib compression (Images transparency,...)
This commit is contained in:
@@ -37,6 +37,7 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
import java.util.zip.Deflater;
|
||||
import java.util.zip.DeflaterOutputStream;
|
||||
|
||||
/**
|
||||
@@ -1602,9 +1603,9 @@ public class SWFOutputStream extends OutputStream {
|
||||
}
|
||||
|
||||
public void writeBytesZlib(byte data[]) throws IOException {
|
||||
DeflaterOutputStream deflater = new DeflaterOutputStream(this);
|
||||
DeflaterOutputStream deflater = new DeflaterOutputStream(this,new Deflater(9));
|
||||
deflater.write(data);
|
||||
deflater.flush();
|
||||
deflater.finish();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.abc.CopyOutputStream;
|
||||
import com.jpexs.decompiler.flash.tags.base.AloneTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ImageTag;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -27,6 +29,8 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag {
|
||||
@@ -45,10 +49,18 @@ public class DefineBitsJPEG3Tag extends ImageTag implements AloneTag {
|
||||
imageData = data;
|
||||
if (ImageTag.getImageFormat(data).equals("jpg")) {
|
||||
BufferedImage image = getImage(new ArrayList<Tag>());
|
||||
bitmapAlphaData = new byte[image.getWidth() * image.getHeight()];
|
||||
for (int i = 0; i < bitmapAlphaData.length; i++) {
|
||||
bitmapAlphaData[i] = (byte) 255;
|
||||
byte ba[] = new byte[image.getWidth() * image.getHeight()];
|
||||
for (int i = 0; i < ba.length; i++) {
|
||||
ba[i] = (byte) 255;
|
||||
}
|
||||
ByteArrayOutputStream baos=new ByteArrayOutputStream();
|
||||
SWFOutputStream sos=new SWFOutputStream(baos, SWF.DEFAULT_VERSION);
|
||||
try {
|
||||
sos.writeBytesZlib(ba);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(DefineBitsJPEG3Tag.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
bitmapAlphaData = baos.toByteArray();
|
||||
} else {
|
||||
bitmapAlphaData = new byte[0];
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.jpexs.decompiler.flash.tags;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.SWFInputStream;
|
||||
import com.jpexs.decompiler.flash.SWFOutputStream;
|
||||
import com.jpexs.decompiler.flash.tags.base.AloneTag;
|
||||
@@ -27,6 +28,8 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
/**
|
||||
@@ -56,10 +59,18 @@ public class DefineBitsJPEG4Tag extends ImageTag implements AloneTag {
|
||||
imageData = data;
|
||||
if (ImageTag.getImageFormat(data).equals("jpg")) {
|
||||
BufferedImage image = getImage(new ArrayList<Tag>());
|
||||
bitmapAlphaData = new byte[image.getWidth() * image.getHeight()];
|
||||
for (int i = 0; i < bitmapAlphaData.length; i++) {
|
||||
bitmapAlphaData[i] = (byte) 255;
|
||||
byte ba[] = new byte[image.getWidth() * image.getHeight()];
|
||||
for (int i = 0; i < ba.length; i++) {
|
||||
ba[i] = (byte) 255;
|
||||
}
|
||||
ByteArrayOutputStream baos=new ByteArrayOutputStream();
|
||||
SWFOutputStream sos=new SWFOutputStream(baos, SWF.DEFAULT_VERSION);
|
||||
try {
|
||||
sos.writeBytesZlib(ba);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(DefineBitsJPEG4Tag.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
bitmapAlphaData = baos.toByteArray();
|
||||
} else {
|
||||
bitmapAlphaData = new byte[0];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user