This commit is contained in:
Denis Molony 2017-01-25 12:38:00 +11:00
parent 0a5fba86b0
commit a23d4b5a2c
5 changed files with 62 additions and 14 deletions

View File

@ -9,7 +9,6 @@ import java.util.List;
import javax.imageio.ImageIO;
import com.bytezone.diskbrowser.prodos.ProdosConstants;
import com.bytezone.diskbrowser.utilities.HexFormatter;
public abstract class HiResImage extends AbstractFile
{
@ -146,7 +145,7 @@ public abstract class HiResImage extends AbstractFile
if (auxType == 1)
auxText = "Packed Super Hi-Res Image";
else if (auxType == 2)
auxText = "Super Hi-Res Image";
auxText = "Super Hi-Res Image (Apple Preferred)";
else if (auxType == 3)
auxText = "Packed QuickDraw II PICT File";
break;
@ -167,7 +166,7 @@ public abstract class HiResImage extends AbstractFile
if (unpackedBuffer != null)
{
text.append (String.format ("%nUnpacked : %,d%n%n", unpackedBuffer.length));
text.append (HexFormatter.format (unpackedBuffer));
// text.append (HexFormatter.format (unpackedBuffer));
}
return text.toString ();

View File

@ -6,6 +6,8 @@ public class PackedSHR extends HiResImage
public PackedSHR (String name, byte[] buffer, int fileType, int auxType)
{
super (name, buffer, fileType, auxType);
System.out.println ("SHR aux=1");
}
@Override

View File

@ -1,5 +1,8 @@
package com.bytezone.diskbrowser.applefile;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.util.ArrayList;
import java.util.List;
@ -8,6 +11,7 @@ import com.bytezone.diskbrowser.utilities.HexFormatter;
public class SHRPictureFile extends HiResImage
{
List<Block> blocks = new ArrayList<Block> ();
Main mainBlock;
public SHRPictureFile (String name, byte[] buffer, int fileType, int auxType)
{
@ -23,29 +27,58 @@ public class SHRPictureFile extends HiResImage
System.arraycopy (buffer, ptr, data, 0, data.length);
if ("MAIN".equals (kind))
blocks.add (new Main (kind, data));
{
mainBlock = new Main (kind, data);
blocks.add (mainBlock);
}
else
blocks.add (new Block (kind, data));
ptr += len;
}
createImage ();
}
@Override
protected void createMonochromeImage ()
{
makeScreen (unpackedBuffer);
}
@Override
protected void createColourImage ()
{
image = new BufferedImage (320, 200, BufferedImage.TYPE_INT_RGB);
DataBuffer dataBuffer = image.getRaster ().getDataBuffer ();
int element = 0;
int ptr = 0;
for (int row = 0; row < 200; row++)
{
DirEntry dirEntry = mainBlock.scanLineDirectory[row];
int hi = dirEntry.mode & 0xFF00;
int lo = dirEntry.mode & 0x00FF;
ColorTable colorTable = mainBlock.colorTables[lo & 0x0F];
boolean fillMode = (lo & 0x20) != 0;
if (fillMode)
System.out.println ("fillmode " + fillMode);
for (int col = 0; col < 160; col++)
{
int left = (unpackedBuffer[ptr] & 0xF0) >> 4;
int right = unpackedBuffer[ptr] & 0x0F;
dataBuffer.setElem (element++, colorTable.entries[left].color.getRGB ());
dataBuffer.setElem (element++, colorTable.entries[right].color.getRGB ());
ptr++;
}
}
}
@Override
public String getText ()
{
StringBuilder text = new StringBuilder (super.getText ());
text.append ("\n\n");
for (Block block : blocks)
{
@ -53,8 +86,11 @@ public class SHRPictureFile extends HiResImage
text.append ("\n\n");
}
text.deleteCharAt (text.length () - 1);
text.deleteCharAt (text.length () - 1);
if (blocks.size () > 0)
{
text.deleteCharAt (text.length () - 1);
text.deleteCharAt (text.length () - 1);
}
return text.toString ();
}
@ -134,7 +170,7 @@ public class SHRPictureFile extends HiResImage
if (true)
{
byte[] newBuf = new byte[32768];
unpackedBuffer = new byte[32768];
ptr = 0;
for (int line = 0; line < numScanLines; line++)
{
@ -144,9 +180,8 @@ public class SHRPictureFile extends HiResImage
System.out.println ("Odd number of bytes in empty buffer in " + name);
break;
}
ptr = unpackLine (lineBuffer, newBuf, ptr);
ptr = unpackLine (lineBuffer, unpackedBuffer, ptr);
}
makeScreen (newBuf);
}
}
@ -309,10 +344,15 @@ public class SHRPictureFile extends HiResImage
class ColorEntry
{
int value; // 0RGB
Color color;
public ColorEntry (byte[] data, int offset)
{
value = HexFormatter.unsignedShort (data, offset);
int red = (value & 0x0F00) >>> 8 | (value & 0x0F00) >>> 4;
int green = (value & 0x00F0) | (value & 0x00F0) >>> 4;
int blue = (value & 0x000F) | (value & 0x000F) << 4;
color = new Color (red, green, blue);
}
@Override

View File

@ -35,6 +35,7 @@ class DataPanel extends JTabbedPane
JTextArea formattedText;
ImagePanel imagePanel; // internal class
boolean debug;
boolean imageVisible = false;
@ -180,12 +181,18 @@ class DataPanel extends JTabbedPane
public void setDebug (boolean value)
{
debug = value;
if (currentDataSource instanceof VisicalcFile)
{
VisicalcFile visicalcFile = (VisicalcFile) currentDataSource;
VisicalcFile.setDebug (value);
setText (formattedText, visicalcFile.getText ());
}
else if (currentDataSource instanceof HiResImage)
{
setDataSource (currentDataSource); // toggles text/image
}
}
private void setTabsFont (Font font)
@ -261,7 +268,7 @@ class DataPanel extends JTabbedPane
}
BufferedImage image = dataSource.getImage ();
if (image == null)
if (image == null || debug)
removeImage ();
else
{
@ -330,7 +337,7 @@ class DataPanel extends JTabbedPane
if (true)
{
if (width < 400)
if (width < 400 && width > 0)
scale = (400 - 1) / width + 1;
else
scale = 1;

View File

@ -203,7 +203,7 @@ public class MenuHandler
prefs.putBoolean (PREFS_SHOW_FREE_SECTORS, showFreeSectorsItem.isSelected ());
prefs.putBoolean (PREFS_COLOUR_QUIRKS, colourQuirksItem.isSelected ());
prefs.putBoolean (PREFS_MONOCHROME, monochromeItem.isSelected ());
prefs.putBoolean (PREFS_DEBUGGING, debuggingItem.isSelected ());
// prefs.putBoolean (PREFS_DEBUGGING, debuggingItem.isSelected ());
prefs.putInt (PREFS_PALETTE,
HiResImage.getPaletteFactory ().getCurrentPaletteIndex ());
}
@ -217,7 +217,7 @@ public class MenuHandler
showFreeSectorsItem.setSelected (prefs.getBoolean (PREFS_SHOW_FREE_SECTORS, false));
colourQuirksItem.setSelected (prefs.getBoolean (PREFS_COLOUR_QUIRKS, false));
monochromeItem.setSelected (prefs.getBoolean (PREFS_MONOCHROME, false));
debuggingItem.setSelected (prefs.getBoolean (PREFS_DEBUGGING, false));
// debuggingItem.setSelected (prefs.getBoolean (PREFS_DEBUGGING, false));
int paletteIndex = prefs.getInt (PREFS_PALETTE, 0);
PaletteFactory paletteFactory = HiResImage.getPaletteFactory ();