This commit is contained in:
Denis Molony 2017-01-25 16:26:37 +11:00
parent 195a4af674
commit df118b4709
2 changed files with 18 additions and 2 deletions

View File

@ -55,7 +55,7 @@ public abstract class HiResImage extends AbstractFile
protected void createImage ()
{
if (isGif (buffer) || isPng (buffer))
if (isGif (buffer) || isPng (buffer) || isBmp (buffer))
makeImage ();
else if (monochrome)
createMonochromeImage ();
@ -287,6 +287,11 @@ public abstract class HiResImage extends AbstractFile
{
e.printStackTrace ();
}
catch (IndexOutOfBoundsException e) // some BMP files cause this
{
System.out.println ("Error in makeImage()");
System.out.println (e.getMessage ());
}
}
public static boolean isGif (byte[] buffer)
@ -310,6 +315,15 @@ public abstract class HiResImage extends AbstractFile
return true;
}
public static boolean isBmp (byte[] buffer)
{
if (buffer.length < 2)
return false;
String text = new String (buffer, 0, 2);
return text.equals ("BM");
}
public static PaletteFactory getPaletteFactory ()
{
return paletteFactory;

View File

@ -270,7 +270,9 @@ class FileEntry extends CatalogEntry implements ProdosConstants
file = new ShapeTable (name, exactBuffer);
else if (SimpleText.isHTML (exactBuffer))
file = new SimpleText (name, exactBuffer);
else if (HiResImage.isGif (exactBuffer))
else if (HiResImage.isGif (exactBuffer) || HiResImage.isPng (exactBuffer))
file = new OriginalHiResImage (name, exactBuffer, auxType);
else if (name.endsWith (".BMP") && HiResImage.isBmp (exactBuffer))
file = new OriginalHiResImage (name, exactBuffer, auxType);
else if (link != null)
{