mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-27 13:40:46 +00:00
Fixed some tags,
Image export stub
This commit is contained in:
@@ -22,20 +22,31 @@ import com.jpexs.asdec.helpers.Highlighting;
|
||||
import com.jpexs.asdec.tags.DefineBitsJPEG2Tag;
|
||||
import com.jpexs.asdec.tags.DefineBitsJPEG3Tag;
|
||||
import com.jpexs.asdec.tags.DefineBitsJPEG4Tag;
|
||||
import com.jpexs.asdec.tags.DefineBitsLossless2Tag;
|
||||
import com.jpexs.asdec.tags.DefineBitsLosslessTag;
|
||||
import com.jpexs.asdec.tags.DefineBitsTag;
|
||||
import com.jpexs.asdec.tags.DoABCTag;
|
||||
import com.jpexs.asdec.tags.JPEGTablesTag;
|
||||
import com.jpexs.asdec.tags.Tag;
|
||||
import com.jpexs.asdec.tags.base.ASMSource;
|
||||
import com.jpexs.asdec.tags.base.TagName;
|
||||
import com.jpexs.asdec.types.ALPHABITMAPDATA;
|
||||
import com.jpexs.asdec.types.ALPHACOLORMAPDATA;
|
||||
import com.jpexs.asdec.types.BITMAPDATA;
|
||||
import com.jpexs.asdec.types.COLORMAPDATA;
|
||||
import com.jpexs.asdec.types.RECT;
|
||||
import com.jpexs.asdec.types.RGB;
|
||||
import com.jpexs.asdec.types.RGBA;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.zip.DeflaterOutputStream;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
/**
|
||||
* Class representing SWF file
|
||||
@@ -483,27 +494,27 @@ public class SWF {
|
||||
}
|
||||
|
||||
for (Tag t : tags) {
|
||||
if ((t instanceof DefineBitsJPEG2Tag)||(t instanceof DefineBitsJPEG3Tag)||(t instanceof DefineBitsJPEG4Tag)) {
|
||||
byte imageData[]=null;
|
||||
int characterID=0;
|
||||
if(t instanceof DefineBitsJPEG2Tag){
|
||||
imageData=((DefineBitsJPEG2Tag)t).imageData;
|
||||
characterID=((DefineBitsJPEG2Tag)t).characterID;
|
||||
if ((t instanceof DefineBitsJPEG2Tag) || (t instanceof DefineBitsJPEG3Tag) || (t instanceof DefineBitsJPEG4Tag)) {
|
||||
byte imageData[] = null;
|
||||
int characterID = 0;
|
||||
if (t instanceof DefineBitsJPEG2Tag) {
|
||||
imageData = ((DefineBitsJPEG2Tag) t).imageData;
|
||||
characterID = ((DefineBitsJPEG2Tag) t).characterID;
|
||||
}
|
||||
if(t instanceof DefineBitsJPEG3Tag){
|
||||
imageData=((DefineBitsJPEG3Tag)t).imageData;
|
||||
characterID=((DefineBitsJPEG3Tag)t).characterID;
|
||||
if (t instanceof DefineBitsJPEG3Tag) {
|
||||
imageData = ((DefineBitsJPEG3Tag) t).imageData;
|
||||
characterID = ((DefineBitsJPEG3Tag) t).characterID;
|
||||
}
|
||||
if(t instanceof DefineBitsJPEG4Tag){
|
||||
imageData=((DefineBitsJPEG4Tag)t).imageData;
|
||||
characterID=((DefineBitsJPEG4Tag)t).characterID;
|
||||
if (t instanceof DefineBitsJPEG4Tag) {
|
||||
imageData = ((DefineBitsJPEG4Tag) t).imageData;
|
||||
characterID = ((DefineBitsJPEG4Tag) t).characterID;
|
||||
}
|
||||
|
||||
|
||||
FileOutputStream fos = null;
|
||||
try {
|
||||
fos = new FileOutputStream(outdir + File.separator + characterID + "."+getImageFormat(imageData));
|
||||
fos = new FileOutputStream(outdir + File.separator + characterID + "." + getImageFormat(imageData));
|
||||
if (hasErrorHeader(imageData)) {
|
||||
fos.write(imageData,4,imageData.length-4);
|
||||
fos.write(imageData, 4, imageData.length - 4);
|
||||
} else {
|
||||
fos.write(imageData);
|
||||
}
|
||||
@@ -517,6 +528,75 @@ public class SWF {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (t instanceof DefineBitsLosslessTag) {
|
||||
DefineBitsLosslessTag dbl = (DefineBitsLosslessTag) t;
|
||||
BufferedImage bi = new BufferedImage(dbl.bitmapWidth, dbl.bitmapHeight, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics g = bi.getGraphics();
|
||||
COLORMAPDATA colorMapData = null;
|
||||
BITMAPDATA bitmapData = null;
|
||||
if (dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_8BIT_COLORMAPPED) {
|
||||
colorMapData = dbl.getColorMapData();
|
||||
}
|
||||
if ((dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) || (dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_24BIT_RGB)) {
|
||||
bitmapData = dbl.getBitmapData();
|
||||
}
|
||||
int pos32aligned = 0;
|
||||
int pos = 0;
|
||||
for (int y = 0; y < dbl.bitmapHeight; y++) {
|
||||
for (int x = 0; x < dbl.bitmapWidth; x++) {
|
||||
if (dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_8BIT_COLORMAPPED) {
|
||||
RGB color = colorMapData.colorTableRGB[colorMapData.colorMapPixelData[pos32aligned]];
|
||||
g.setColor(new Color(color.red, color.green, color.blue));
|
||||
}
|
||||
if (dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_15BIT_RGB) {
|
||||
g.setColor(new Color(bitmapData.bitmapPixelDataPix15[pos].red * 8, bitmapData.bitmapPixelDataPix15[pos].green * 8, bitmapData.bitmapPixelDataPix15[pos].blue * 8));
|
||||
}
|
||||
if (dbl.bitmapFormat == DefineBitsLosslessTag.FORMAT_24BIT_RGB) {
|
||||
g.setColor(new Color(bitmapData.bitmapPixelDataPix24[pos].red, bitmapData.bitmapPixelDataPix24[pos].green, bitmapData.bitmapPixelDataPix24[pos].blue));
|
||||
}
|
||||
g.fillRect(x, y, 1, 1);
|
||||
pos32aligned++;
|
||||
pos++;
|
||||
}
|
||||
while ((pos32aligned % 4 != 0)) {
|
||||
pos32aligned++;
|
||||
}
|
||||
}
|
||||
ImageIO.write(bi, "PNG", new File(outdir + File.separator + dbl.characterID + ".png"));
|
||||
}
|
||||
if (t instanceof DefineBitsLossless2Tag) {
|
||||
DefineBitsLossless2Tag dbl = (DefineBitsLossless2Tag) t;
|
||||
BufferedImage bi = new BufferedImage(dbl.bitmapWidth, dbl.bitmapHeight, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics g = bi.getGraphics();
|
||||
ALPHACOLORMAPDATA colorMapData = null;
|
||||
ALPHABITMAPDATA bitmapData = null;
|
||||
if (dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_8BIT_COLORMAPPED) {
|
||||
colorMapData = dbl.getColorMapData();
|
||||
}
|
||||
if ((dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_15BIT_RGB) || (dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_24BIT_RGB)) {
|
||||
bitmapData = dbl.getBitmapData();
|
||||
}
|
||||
int pos32aligned = 0;
|
||||
int pos = 0;
|
||||
for (int y = 0; y < dbl.bitmapHeight; y++) {
|
||||
for (int x = 0; x < dbl.bitmapWidth; x++) {
|
||||
if ((dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_8BIT_COLORMAPPED)) {
|
||||
RGBA color = colorMapData.colorTableRGB[colorMapData.colorMapPixelData[pos32aligned]];
|
||||
g.setColor(new Color(color.red, color.green, color.blue, color.alpha));
|
||||
}
|
||||
if ((dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_15BIT_RGB) || (dbl.bitmapFormat == DefineBitsLossless2Tag.FORMAT_24BIT_RGB)) {
|
||||
g.setColor(new Color(bitmapData.bitmapPixelData[pos].red, bitmapData.bitmapPixelData[pos].green, bitmapData.bitmapPixelData[pos].blue, bitmapData.bitmapPixelData[pos].alpha));
|
||||
}
|
||||
g.fillRect(x, y, 1, 1);
|
||||
pos32aligned++;
|
||||
pos++;
|
||||
}
|
||||
while ((pos32aligned % 4 != 0)) {
|
||||
pos32aligned++;
|
||||
}
|
||||
}
|
||||
ImageIO.write(bi, "PNG", new File(outdir + File.separator + dbl.characterID + ".png"));
|
||||
}
|
||||
if ((jtt != null) && (t instanceof DefineBitsTag)) {
|
||||
DefineBitsTag dbt = (DefineBitsTag) t;
|
||||
FileOutputStream fos = null;
|
||||
|
||||
Reference in New Issue
Block a user