| Author |
Message |
|
|
Anonymous
|
Hi,
I've been able to extract GIF images no problem. The JPEG format is proving troublesome. Any ideas how to convert the byte array from getJpegData() to a .jpg file? I'll keep hacking away at it but I'd appreciate any help. (Most source code available on the net uses java.awt.image.Image, when I think java.awt.image.BufferedImage or java.awt.image.WritableRaster would be more appropriate in this case.)Will post source code when working.
Thanks in advance,
Alex
|
|
|
 |
|
|
Anonymous
|
In case anyone else is curious, the byte[] from getJpegData() can be written to a file and read as valid jpg if you ignore the first 4 bytes.
if (obj instanceof DefineBitsJPEG2) {
dbj = (DefineBitsJPEG2)obj;
id = dbj.getCharacterId();
bytJpeg = dbj.getJpegData();
try {
fos = new FileOutputStream(String.format("character_%1$03d.jpg", id));
//
// skip first 4 bytes
//
for (j = 4; j < bytJpeg.length; j += 256) {
if (bytJpeg.length - j < 256) {
fos.write(bytJpeg, j, bytJpeg.length - j);
} else {
fos.write(bytJpeg, j, 256);
}
}
fos.flush();
fos.close();
} catch (FileNotFoundException fnfe) {
System.out.println("fnfe");
} catch (IOException ioe) {
System.out.println("ioe");
}
}
|
|
|
|
 |
|
|
Ralf

Joined: Jul 20, 2005
Messages: 127
Location: Germany
Offline
|
Thanks a lot for sharing your code! If you want to share more, you can also use the wiki:
http://wiki.jswiff.com
|
|
|
 |
|
|
jack
Joined: Apr 12, 2007
Messages: 2
Offline
|
if you ignore the first 4 bytes,the jpg which is from swf is nothing;
help?
|
|
|
 |
|
|