BMP export fix

BMP import for Images,Shapes
This commit is contained in:
Jindra Petřík
2014-11-22 21:18:28 +01:00
parent 4627afa5df
commit 686a527246
19 changed files with 2075 additions and 2051 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);