Merge pull request #19 from guinotphil/spifix

Fix issue with JMagick Spi Providers
This commit is contained in:
Harald Kuhr 2013-12-23 02:45:43 -08:00
commit af245a80d9
3 changed files with 8 additions and 3 deletions

View File

@ -46,7 +46,7 @@ import java.util.Locale;
*/
abstract class JMagickImageReaderSpiSupport extends ImageReaderSpi {
final static boolean AVAILABLE = SystemUtil.isClassAvailable("com.twelvemonkeys.imageio.plugins.jmagick.JMagick");
final static boolean AVAILABLE = SystemUtil.isClassAvailable("com.twelvemonkeys.imageio.plugins.jmagick.JMagick", JMagickImageReaderSpiSupport.class);
/**
* Creates a JMagickImageReaderSpiSupport

View File

@ -52,12 +52,13 @@ public class JPEGImageReaderSpi extends JMagickImageReaderSpiSupport {
boolean canDecode(ImageInputStream pSource) throws IOException {
// new byte[][] {new byte[] {(byte) 0xff, (byte) 0xd8, (byte) 0xff, (byte) 0xe0},
// new byte[] {(byte) 0xff, (byte) 0xd8, (byte) 0xff, (byte) 0xe1}}, // JPEG
// new byte[][] {new byte[] {(byte) 0xff, (byte) 0xd8, (byte) 0xff, (byte) 0xed}}, // PHOTOSHOP 3 JPEG
// new byte[][] {new byte[] {(byte) 0xff, (byte) 0xd8, (byte) 0xff, (byte) 0xee}}, // JPG
byte[] magic = new byte[4];
pSource.readFully(magic);
return magic[0] == (byte) 0xFF && magic[1] == (byte) 0xD8 && magic[2] == (byte) 0xFF &&
(magic[3] == (byte) 0xE0 || magic[0] == (byte) 0xE1 || magic[0] == (byte) 0xEE);
(magic[3] == (byte) 0xE0 || magic[3] == (byte) 0xE1 || magic[3] == (byte) 0xED || magic[3] == (byte) 0xEE);
}

View File

@ -63,7 +63,11 @@ public class TargaImageReaderSpi extends JMagickImageReaderSpiSupport {
// new byte[] {-1, 0x01, 0x20}, // Type 31: Compressed CM
// new byte[] {-1, 0x01, 0x21}, // Type 32: Compressed CM, 4 pass
// },
pSource.seek(pSource.length() - 18);
try {
pSource.seek(pSource.length() - 18);
} catch (IndexOutOfBoundsException e) {
return false;
}
byte[] magic = new byte[18];
pSource.readFully(magic);