diff --git a/BinxelviewForm.cs b/BinxelviewForm.cs index 70b78a4..5449fdd 100644 --- a/BinxelviewForm.cs +++ b/BinxelviewForm.cs @@ -329,7 +329,7 @@ string parseOption(string optline) valu.EndsWith(".TIF"); bool vga = valu.EndsWith(".VGA"); - if (!openPalette(val,image,vga)) return "Could not load palette file: "+val+"\n"+palette_error; + if (!loadPalette(val,image,vga)) return "Could not load palette file: "+val+"\n"+palette_error; return ""; } if (opt == "AUTOPAL") @@ -1043,9 +1043,19 @@ void reloadPresets() } } - bool openPalette(string path, bool image, bool sixbit_vga) + void initCustomPalette() { + // initialize palette to grey stripes + for (int i=0; i<(PALETTE_DIM*PALETTE_DIM); ++i) + { + int v = ((i&1)==1) ? 0x84 : 0x74; + setPalette(i,v,v,v); + } palette_mode = PaletteMode.PALETTE_CUSTOM; + } + + bool loadPalette(string path, bool image, bool sixbit_vga) + { if (image) { @@ -1066,6 +1076,8 @@ bool openPalette(string path, bool image, bool sixbit_vga) palette_error = "Image does not contain a palette."; return false; } + + initCustomPalette(); for (int i=0; (i<(PALETTE_DIM*PALETTE_DIM)) && (i 0) - { - MessageBox.Show("Command line error:\n" + arg_err,"Binxelview"); - } + if (arg_err.Length > 0) MessageBox.Show("Command line error:\n" + arg_err,"Binxelview"); scrollRange(); redrawPreset(); @@ -1664,7 +1684,7 @@ private void buttonLoadPal_Click(object sender, EventArgs e) "All files, RGB24 (*.*)|*.*"; if (d.ShowDialog() == DialogResult.OK) { - if (openPalette(d.FileName,d.FilterIndex==2,d.FilterIndex==3)) + if (loadPalette(d.FileName,d.FilterIndex==2,d.FilterIndex==3)) { refreshPalette(); redrawPixels(); diff --git a/readme.txt b/readme.txt index 6ac925e..49781c9 100644 --- a/readme.txt +++ b/readme.txt @@ -128,6 +128,10 @@ otherwise an automatic RGB or Greyscale palette can be applied. Custom palettes are 24-bit RGB triples (8 bits for each component). Click on a colour in the palette box to edit it. +You can create a default palette named "default.pal" to be loaded automatically at startup. +As with presets, it will check the current working directory for "default.pal" first, +before also checking the directory of the executable. + If you are able to view a block of palette data in a file, you can quickly copy it to the palette. Right click on the first pixel of the block, and the palette will be generated with the colour of each pixel starting with that one. Note that this assumes contiguous pixel data, and will not account @@ -235,6 +239,7 @@ Changes - VGA Palette preset. - Indicate hexadecimal position with bold font. - Command line arguments for options. +- Default palette ability. 1.5.0.0 (2020-07-31) - Twiddle option for inspecting textures stored with morton ordering of pixels.