mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-07-13 19:08:07 +00:00
BMP export fix
BMP import for Images,Shapes
This commit is contained in:
@@ -131,12 +131,8 @@ public class BMPFile extends Component {
|
||||
int pad;
|
||||
int padCount;
|
||||
byte rgb[] = new byte[3];
|
||||
size = (biWidth * biHeight) - 1;
|
||||
pad = 4 - ((biWidth * 3) % 4);
|
||||
if (pad == 4) // <==== Bug correction
|
||||
{
|
||||
pad = 0; // <==== Bug correction
|
||||
}
|
||||
size = (biWidth * biHeight);
|
||||
pad = (biWidth * 3) % 4;
|
||||
rowCount = 1;
|
||||
padCount = 0;
|
||||
rowIndex = size - biWidth;
|
||||
|
||||
@@ -21,7 +21,11 @@ import com.jpexs.decompiler.flash.tags.DefineBitsJPEG2Tag;
|
||||
import com.jpexs.decompiler.flash.tags.DefineBitsTag;
|
||||
import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ImageTag;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -30,6 +34,14 @@ import java.io.IOException;
|
||||
public class ImageImporter extends TagImporter {
|
||||
|
||||
public Tag importImage(ImageTag it, byte[] newData) throws IOException {
|
||||
|
||||
if (newData[0] == 'B' && newData[1] == 'M') {
|
||||
BufferedImage b = ImageIO.read(new ByteArrayInputStream(newData));
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ImageIO.write(b, "PNG", baos);
|
||||
newData = baos.toByteArray();
|
||||
}
|
||||
|
||||
if (it instanceof DefineBitsTag) {
|
||||
SWF swf = it.getSwf();
|
||||
DefineBitsJPEG2Tag jpeg2Tag = new DefineBitsJPEG2Tag(swf, it.getOriginalRange(), it.getCharacterId(), newData);
|
||||
|
||||
@@ -26,8 +26,12 @@ import com.jpexs.decompiler.flash.tags.Tag;
|
||||
import com.jpexs.decompiler.flash.tags.base.BoundedTag;
|
||||
import com.jpexs.decompiler.flash.tags.base.ShapeTag;
|
||||
import com.jpexs.decompiler.flash.types.SHAPEWITHSTYLE;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -37,6 +41,14 @@ public class ShapeImporter {
|
||||
|
||||
public Tag importImage(ShapeTag st, byte[] newData) throws IOException {
|
||||
SWF swf = st.getSwf();
|
||||
|
||||
if(newData[0] == 'B' && newData[1] == 'M'){
|
||||
BufferedImage b = ImageIO.read(new ByteArrayInputStream(newData));
|
||||
ByteArrayOutputStream baos=new ByteArrayOutputStream();
|
||||
ImageIO.write(b, "PNG", baos);
|
||||
newData = baos.toByteArray();
|
||||
}
|
||||
|
||||
DefineBitsJPEG2Tag jpeg2Tag = new DefineBitsJPEG2Tag(swf, null, swf.getNextCharacterId(), newData);
|
||||
jpeg2Tag.setModified(true);
|
||||
swf.tags.add(jpeg2Tag);
|
||||
|
||||
Reference in New Issue
Block a user