Palettes working correctly

This commit is contained in:
Denis Molony 2017-01-15 07:58:07 +11:00
parent 93049c19d5
commit f60cb46de8
7 changed files with 34 additions and 20 deletions

View File

@ -83,6 +83,7 @@ public class DoubleHiResImage extends HiResImage
@Override
protected void createColourImage ()
{
paletteIndex = paletteFactory.getCurrentPaletteIndex ();
Palette palette = paletteFactory.getCurrentPalette ();
int[] colours = palette.getColours ();

View File

@ -24,6 +24,7 @@ public abstract class HiResImage extends AbstractFile
protected int fileType;
protected int auxType;
protected byte[] unpackedBuffer;
protected int paletteIndex;
public HiResImage (String name, byte[] buffer)
{
@ -82,6 +83,12 @@ public abstract class HiResImage extends AbstractFile
protected abstract void createColourImage ();
public void checkPalette ()
{
if (!monochrome && paletteIndex != paletteFactory.getCurrentPaletteIndex ())
createImage ();
}
public void setPalette ()
{
if (!monochrome)

View File

@ -71,6 +71,7 @@ public class OriginalHiResImage extends HiResImage
@Override
protected void createColourImage ()
{
paletteIndex = paletteFactory.getCurrentPaletteIndex ();
int rows = buffer.length <= 8192 ? 192 : 384;
image = new BufferedImage (280, rows, BufferedImage.TYPE_INT_RGB);
DataBuffer dataBuffer = image.getRaster ().getDataBuffer ();

View File

@ -10,24 +10,24 @@ public class PaletteFactory
public PaletteFactory ()
{
palettes.add (new Palette ("Palette 1",
new int[] { 0x000000, // 0 black A
0xFF0000, // 1 red C
0xA52A2A, // 2 brown E (8)
0xFFA500, // 3 orange G (9)
0x008000, // 4 dark green I
0x808080, // 5 grey1 K
0x90EE90, // 6 light green M (C)
0xFFFF00, // 7 yellow O (D)
0x00008B, // 8 dark blue B (2)
0x800080, // 9 purple D (3)
0xC0C0C0, // A grey2 F
0xFFC0CB, // B pink H
0x00BFFF, // C med blue J (6)
0x87CEFA, // D light blue L (7)
0x00FFFF, // E aqua N
0xFFFFFF // F white P
}));
// palettes.add (new Palette ("Palette 1",
// new int[] { 0x000000, // 0 black A
// 0xFF0000, // 1 red C
// 0xA52A2A, // 2 brown E (8)
// 0xFFA500, // 3 orange G (9)
// 0x008000, // 4 dark green I
// 0x808080, // 5 grey1 K
// 0x90EE90, // 6 light green M (C)
// 0xFFFF00, // 7 yellow O (D)
// 0x00008B, // 8 dark blue B (2)
// 0x800080, // 9 purple D (3)
// 0xC0C0C0, // A grey2 F
// 0xFFC0CB, // B pink H
// 0x00BFFF, // C med blue J (6)
// 0x87CEFA, // D light blue L (7)
// 0x00FFFF, // E aqua N
// 0xFFFFFF // F white P
// }));
palettes.add (new Palette ("Virtual II",
new int[] { 0x000000, // 0 black

View File

@ -269,6 +269,11 @@ class DataPanel extends JTabbedPane
}
else
{
if (dataSource instanceof HiResImage)
{
((HiResImage) dataSource).checkPalette ();
image = dataSource.getImage ();
}
imagePanel.setImage (image);
imagePane.setViewportView (imagePanel);
// if (!menuHandler.colourMenu.isEnabled ())

View File

@ -27,7 +27,7 @@ public class NextPaletteAction extends AbstractAction
public void actionPerformed (ActionEvent e)
{
Palette palette = owner.cyclePalette (CycleDirection.FORWARDS);
owner.selectPalette (palette);
// owner.selectPalette (palette);
if (palette != null)
{

View File

@ -27,7 +27,7 @@ public class PreviousPaletteAction extends AbstractAction
public void actionPerformed (ActionEvent e)
{
Palette palette = owner.cyclePalette (CycleDirection.BACKWARDS);
owner.selectPalette (palette);
// owner.selectPalette (palette);
if (palette != null)
{